Sory mas mau nanya lagi neee... hehe
saya lagi buat quis online dimana pada soal dan jawabannya bisa menggunakan teks ataupun gambar, gimana si caranya input teks/gambar kedalam satu field yang sama,.
ini tabelnya dan scriptnya...
CREATE TABLE IF NOT EXISTS `banksoal` (
  `soalid` int(5) NOT NULL AUTO_INCREMENT,
  `topik` varchar(50) NOT NULL,
  `pertanyaan` text NOT NULL,
  `pilihan_a` tinytext NOT NULL,
  `pilihan_b` tinytext NOT NULL,
  `pilihan_c` tinytext NOT NULL,
  `pilihan_d` tinytext NOT NULL,
  `pilihan_e` tinytext NOT NULL,
  `jawaban` varchar(1) NOT NULL,
  PRIMARY KEY (`soalid`),
  KEY `topik` (`topik`)
) ENGINE=InnoDB
<div>
<?php
	include "koneksi.php";
	if (isset($_POST['submit'])){
		$topik=$_POST['topik'];
		$pertanyaan=$_POST['pertanyaan'];
		$pilihan_a=$_POST['pilihan_a'];
		$pilihan_b=$_POST['pilihan_b'];
		$pilihan_c=$_POST['pilihan_c'];
		$pilihan_d=$_POST['pilihan_d'];
		$pilihan_e=$_POST['pilihan_e'];
		$jawaban=$_POST['jawaban'];
		
		$query = "insert into banksoal values ('','$topik','$pertanyaan','$pilihan_a','$pilihan_b','$pilihan_c','$pilihan_d','$pilihan_e','$jawaban')";
		$input = (mysql_query($query));
		if($input){
			?><script language="javascript">document.location.href="validasi.php";</script><?php
		}else{
			echo mysql_error();
		}
		
	}else{
		unset($_POST['submit']);
	}
	?>

<h1>Input Soal</h1>
  <form action="soal.php" method="post" enctype="multipart/form-data">
    <table class="datatable" align="center">
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><b>TOPIK</b></p>
          </font></td>
        <td> <select name="topik">
            <option value="diksi">Diksi</option>
            <option value="pemahaman wacana">Pemahaman Wacana</option>
            <option value="logika verbal">Logika Verbal</option>
            <option value="deret angka">Deret Angka</option>
            <option value="penalaran aritmatika">Penalaran Aritmatika</option>
            <option value="korelasi makna">Korelasi Makna</option>
          </select> </td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="top"><font size="2" face="verdana"> 
          <p><strong>Pertanyaan</strong></p>
          </font></td>
        <td><textarea cols="23" rows="5" name="pertanyaan"></textarea></td>
      </tr>
      <tr> 
        <td height="37" valign="middle"><font size="2" face="verdana">Gambar</font></td>
        <td><input type="file" name="file" id="file"></td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><strong>Pilihan A</strong></p>
          </font></td>
        <td><input type="text" name="pilihan_a" size="30"/></td>
      </tr>
      <tr> 
        <td height="37" valign="middle"><font size="2" face="verdana">Gambar</font></td>
        <td><input type="file" name="file" id="file"></td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><strong>Pilihan B</strong></p>
          </font></td>
        <td><input type="text" name="pilihan_b" size="30"/></td>
      </tr>
      <tr> 
        <td height="37" valign="middle"><font size="2" face="verdana">Gambar</font></td>
        <td><input type="file" name="file" id="file"></td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><strong>Pilihan C</strong></p>
          </font></td>
        <td><input type="text" name="pilihan_c" size="30"/></td>
      </tr>
      <tr> 
        <td height="37" valign="middle"><font size="2" face="verdana">Gambar</font></td>
        <td><input type="file" name="file" id="file"></td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><strong>Pilihan D</strong></p>
          </font></td>
        <td><input type="text" name="pilihan_d" size="30"/></td>
      </tr>
      <tr> 
        <td height="37" valign="middle"><font size="2" face="verdana">Gambar</font></td>
        <td><input type="file" name="file3" id="file"></td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><strong>Pilihan E</strong></p>
          </font></td>
        <td><input type="text" name="pilihan_e" size="30"/></td>
      </tr>
      <tr> 
        <td height="37" valign="middle"><font size="2" face="verdana">Gambar</font></td>
        <td><input type="file" name="file"></td>
      </tr>
      <tr> 
        <td width="29%" height="37" valign="middle"><font size="2" face="verdana"> 
          <p><strong>JABAWAN</strong></p>
          </font></td>
        <td> <select name="jawaban">
            <option value="a">A</option>
            <option value="b">B</option>
            <option value="c">C</option>
            <option value="d">D</option>
            <option value="e">E</option>
          </select> </td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td width="71%"><input name="submit" type="submit" value="Submit" /> &nbsp;</td>
      </tr>
    </table>
    </form>
</div>

saya belum tau caranya agar si file tersebut asumsinya sama dengan inputan yang di atasnya, agar kalo misalkan di submit masuk ke field yang sama.
Thank you atas bantuanya... :)
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Jul 22, 2012 · 0 Suka · 0 Tidak Suka
dulu ada yang menanyakan hal yang sama
pelajari http://www.myphptutorials.com/tutorials/39/membuat-galeri-foto