mas ,, datanya da berhasil diinput ,, tpi kok kluarnya tuch "array" ea ??? da yg slah ma script q ea mas ..
ne script inputnya mas
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>English Lesson Of Grammar</title>
<link href="css/rheyank_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
<style type="text/css">
<!--
.style1 {color: #75a62c}
.style2 {
color: #333;
font-weight: bold;
}
-->
</style>
</head>
<body>
<div id="body">
<div id="header"></div>
<!-- end of header -->
<div id="menu" class="ddsmoothmenu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="grammar.php">Grammar</a></li>
<li><a href="soal.php" class="selected">Excercise</a></li>
<li><a href="about.php">About</a></li>
</ul>
<br style="clear: left" />
</div> <!-- end of menu -->
<div id="main">
<h2>Masukan Soal !!! </h2>
<div class="col_l">
<br class="cleaner h20" />
<div id="contact_form">
<form name="formsoal" id="formsoal" method="post" action="simpansoal.php">
<p>
<label for="soal">SOAL</label>
<textarea id="soal" name="soal[1]" rows="0" cols="0" class="required"></textarea>
</p>
<p>
<label for="j1">Jawaban A</label>
<input type="text" name="j1[1]" class="required input_field" />
</p>
<p>
<label for="j2">Jawaban B</label>
<input type="text" name="j2[1]" class="validate-email required input_field" />
</p>
<p>
<label for="j3">Jawaban C</label>
<input type="text" name="j3[1]" class="validate-email required input_field" />
</p>
<p>
<label for="j4">Jawaban D</label>
<input type="text" name="j4[1]" class="validate-email required input_field" />
</p>
<p>
<label for="jbenar">Kunci Jawaban</label>
<input type="text" name="jbenar" class="input_field" />
</p>
<p class="no_margin_right">
<label for="tipe">Materi</label>
<input type="text" name="tipe" class="input_field" />
</p>
<div class="cleaner h20"></div>
<input type="submit" value="Save" id="submit" name="submit" class="submit_btn float_l" />
<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
</form>
</div>
</div>
<br class="cleaner" />
</div> <!-- end of main -->
<div id="footer"></div>
<div class="cleaner"></div>
</div> <!-- end of footer -->
<div id="cr_bar_wrapper">
<div id="cr_bar">
Copyright © 2013 Designed by <a href="http://www.facebook.com/rheyank.iwan">Rheyank Iwan</a> </div>
</div>
</body>
</html>
simpannya
<?
//Cek Tombol
if ($_POST){
//Kirimkan Variabel
$soal = $_POST['soal'];
$j1 = $_POST['j1'];
$j2 = $_POST['j2'];
$j3 = $_POST['j3'];
$j4 = $_POST['j4'];
$jbenar = $_POST['jbenar'];
$tipe = $_POST['tipe'];
//validasi data jika pesan kosong
if (empty($_POST['soal'])|| empty($_POST['j1'])|| empty($_POST['j2'])|| empty($_POST['j3'])|| empty($_POST['j4'])|| empty($_POST['jbenar'])|| empty($_POST['tipe']))
{
?>
<script language="JavaScript">
alert('Data Harap Dilengkapi');
document.location='inputsoal.php';
</script>
<?
}
//Jika Validasi Terpenuhi
else
{
//Memanggil File Koneksi Database
mysql_connect("localhost", "root", "12345");
mysql_select_db("english");
//Masukan data ke Table siswa
$query ="INSERT INTO soal VALUES('$id','$soal','$j1','$j2','$j3','$j4','$jbenar','$tipe')";
$hasil = mysql_query($query);
if($hasil){
//Jika Sukses
//echo "Data telah diinput";
?>
<script language="JavaScript">
alert('Data Berhasil diinput');
document.location='viewsoal.php';
</script>
<?
}
else
{
//Jika Gagal
//echo "Data gagal diinput, Silakan Ulangi";
}
}
}
?>
<script language="JavaScript">
alert('Data Gagal diinput,, Silakan ulangi');
document.location='inputsoal.php';
</script>
viewsoalnya
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>English Lesson Of Grammar</title>
<link href="css/rheyank_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
<style type="text/css">
<!--
.style3 {color: #000000; font-weight: bold; }
.style4 {color: #000000}
-->
</style>
</head>
<body>
<div id="body">
<div id="header"></div>
<!-- end of header -->
<div id="menu" class="ddsmoothmenu">
<ul>
<li><a href="index.php" class="selected">Home</a></li>
<li><a href="grammar.php">Grammar</a></li>
<li><a href="soal.php">Excercise</a></li>
<li><a href="about.php">About</a></li>
</ul>
<br style="clear: left" />
</div> <!-- end of menu -->
<div id="main">
<div class="col_l">
<h2 align="center">Daftar Soal Grammar </h2>
<br class="cleaner h20" />
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="tabel">
<tr bgcolor="#8BB2D9">
<th width="4%" height="39" bgcolor="#CCCCCC"><span class="style3">No
</td>
</span>
<th width="6%" bgcolor="#CCCCCC"><span class="style3">Id Soal </td>
</span>
<th width="15%" bgcolor="#CCCCCC"><span class="style3">Pertanyaan</td>
</span>
<th width="14%" bgcolor="#CCCCCC"><span class="style3">Jawaban A
</td>
</span> </th>
<th width="14%" bgcolor="#CCCCCC"><span class="style3">Jawaban B
</td>
</span> </th>
<th width="14%" bgcolor="#CCCCCC"><span class="style3">Jawaban C
</td>
</span> </th>
<th width="14%" bgcolor="#CCCCCC"><span class="style3">Jawaban D
</td>
</span> </th>
<th width="10%" bgcolor="#CCCCCC"><span class="style3">Kunci
</td>
</span> </th>
<th width="10%" bgcolor="#CCCCCC"><span class="style3">Materi</span>
<th width="9%" bgcolor="#CCCCCC"><span class="style3">Action
</td>
</span></tr>
<?
//Memanggil File Koneksi Database
mysql_connect("localhost", "root", "12345");
mysql_select_db("english");
$sql="SELECT * FROM soal ORDER BY id";
$tampil = mysql_query($sql);
while ( $hasil = mysql_fetch_array ($tampil)) {
$id = stripslashes ($hasil);
$soal = stripslashes ($hasil);
$j1 = stripslashes ($hasil);
$j2 = stripslashes ($hasil);
$j3 = stripslashes ($hasil);
$j4 = stripslashes ($hasil);
$jbenar = stripslashes ($hasil);
{
$no++;
?>
<tr align="center">
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr align="center">
<td bgcolor="#FFFFFF"><span class="style4">
<?=$no?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$id?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$soal?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$j1?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$j2?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$j3?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$j4?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$jbenar?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><span class="style4">
<?=$tipe?>
</span>
<div align="center" class="style4"></div></td>
<td bgcolor="#FFFFFF"><div align="center"><a href="editsoal.php=<?=$id?>">Edit</a> | <a href="deletesoal.php=<?=$id?>" OnClick="return confirm('Yakin Data <?=$soal?> akan dihapus');">Delete</a></div></td>
</tr>
<tr align="center">
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"><span class="style4"></span></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<?
}}
?>
</table>
</div>
<div class="cleaner h20"></div>
<a href="inputsoal.php" class="more">Input Soal </a>
</div>
</div>
</div> <!-- end of main -->
<div id="footer"></div>
<div class="cleaner"></div>
<!-- end of footer -->
<div id="cr_bar_wrapper">
<div id="cr_bar">
Copyright © 2013 Designed by <a href="http://www.facebook.com/rheyank.iwan">Rheyank Iwan</a> </div>
</div>
</body>
</html>
ne script untuk nampilin soalnya mas .. yg sudah q ubah sesuai ptunjuk pyn
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>English Lesson Of Grammar</title>
<link href="css/rheyank_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script></head>
<body>
<div id="body">
<div id="header"></div>
<!-- end of header -->
<div id="menu" class="ddsmoothmenu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="grammar.php">Grammar</a>
<ul>
<li><a href="partos.php">Part of Speech</a></li>
<li><a href="tenses.php">Tenses</a></li>
<li><a href="cs.php">Conditional Sentence</a></li>
<li><a href="qwords.php">Question Words</a></li>
<li><a href="grammar.php">All</a></li>
<span></span>
</ul></li>
<li><a href="soal.php" class="selected">Excercise</a></li>
<li><a href="about.php">About</a></li>
</ul>
<br style="clear: left" />
</div> <!-- end of menu -->
<div id="main">
<div class="col_l">
<h2>Exercise</h2>
<?php
// DATABASE
$qlname = "root"; // username
$qlpass = "12345"; // password
$qlserver = "localhost"; // server
$qldbase = "english"; // database name
// jumlah soal yang ditampilkan
$jml = 5;
mysql_connect($qlserver,$qlname,$qlpass);
$conn = mysql_select_db($qldbase);
if(!$conn)
{
echo 'Can\'t find database, maybe server down .....';
exit;
}
//............
if($_POST['user']=="jawab")
{
$jawabTipe = array();
for($i=1; $i<=$jml; $i++) {
$ns = $_POST["s_".$i.""];
$jb = $_POST["j_".$i.""];
$jwb = mysql_query("select * from soal where id='".$ns."' and jbenar='".$jb."'");
if(mysql_num_rows($jwb)==0)
{
$nilai[$i] = 0;
if($jb)
echo 'Jawaban Soal No. '.$i.' - '.$jb.' : <FONT COLOR="red">SALAH</FONT><BR>';
else
echo 'Tidak menjawab soal nomor '.$i.'<br>';
}
else{
$soal = mysql_fetch_array($jwb);
if(!isset($jawabTipe[$soal['tipe']])){
$jawabTipe[$soal['tipe']] = 0;
}
$jawabTipe[$soal['tipe']] += 1;
$nilai[$i] = 1;
if($jb)
echo 'Jawaban Soal No. '.$i.' - '.$jb.' : BENAR<BR>';
// Tempat masukkan jawaban dalam database
// Tempat masukkan jawaban dalam database end
}
}
asort($jawabTipe); //urut dan ambil nilai terendah
echo 'Anda masih lemah di '.key($jawabTipe);
//atau
if(current($jawabTipe) < 5){
echo 'Anda sangat lemah di '.key($jawabTipe);
}
// REKAP NILAI
$nbenar = array_sum($nilai);
$nsalah = $jml-$nbenar;
$ntotal = number_format($nbenar/$jml*100,1);
if($nbenar>0)
{
echo '<br>Rekap Nilai:<br>';
echo '- Jawaban benar : '.$nbenar.' soal<br>';
echo '- Jawaban salah : '.$nsalah.' soal<br>';
// KATEGORI
// Baik Sekali = >=90
// Baik = 80 - 90
// Cukup = 65 - 80
// Kurang = 55 - 65
// Sangat Kurang = < 55
if($ntotal>=90)
$k = 'Baik Sekali';
elseif($ntotal>=80 && $ntotal<90)
$k = 'Baik';
elseif($ntotal>=65 && $ntotal<80)
$k = 'Cukup';
elseif($ntotal>=55 && $ntotal<65)
$k = '<FONT COLOR="red">Kurang</FONT>';
else
$k = '<FONT COLOR="red">Sangat Kurang</FONT>';
// KATEGORI END
echo '- Nilai Total : '.$ntotal.' dari 100 dan Anda termasuk <B><U>'.$k.'</U></B><br>';
}
echo '<br \><A HREF="'.$_PPHP['SELF'].'">Kembali ke soal</A><br \>';
}
else
{
echo '<FORM METHOD="POST" ACTION="">
<INPUT TYPE="hidden" NAME="user" value="jawab">';
echo '<B>Jawablah soal-soal dibawah ini dengan benar</B>';
echo '<OL>';
$sx = mysql_query("SELECT * FROM soal ORDER BY RAND() LIMIT $jml");
$no = 1;
while($x=mysql_fetch_array($sx))
{
echo '<INPUT TYPE="hidden" NAME="s_'.$no.'" value="'.$x[id].'">';
echo '<LI>'.$x[soal].'<br>';
// pilihan
echo '<INPUT TYPE="radio" NAME="j_'.$no.'" value="'.$x[j1].'">'. $x[j1].' ';
echo '<INPUT TYPE="radio" NAME="j_'.$no.'" value="'.$x[j2].'">'. $x[j2].' ';
echo '<INPUT TYPE="radio" NAME="j_'.$no.'" value="'.$x[j3].'">'. $x[j3].' ';
echo '<INPUT TYPE="radio" NAME="j_'.$no.'" value="'.$x[j4].'">'. $x[j4].' ';
echo'</LI>';
$no++;
}
echo '</OL>';
echo '<INPUT TYPE="submit" class="more" value="Jawab Soal">
</FORM>';
}
?>
<div class="cleaner h20"></div>
<a href="#" class="more">More</a>
<br class="cleaner" />
</div>
<br class="cleaner" />
</div> <!-- end of main -->
<div id="footer"></div>
<div class="cleaner"></div>
</div> <!-- end of footer -->
<div id="cr_bar_wrapper">
<div id="cr_bar">
Copyright © 2013 Designed by <a href="http://www.facebook.com/rheyank.iwan">Rheyank Iwan</a> </div>
</div>
</body>
</html>
mhon bantuannya lgi ea mas.. sukses bwt mas ellyx