日期:2014-05-17 浏览次数:20488 次
<?php error_reporting(E_ALL & ~ E_NOTICE); echo "<center>"; if (!$_POST["question_num"]) { echo "<h2>create question</h2>"; echo "<table border=1>"; echo "<form method=post action=".$_SERVER["PHP_SELF"].">"; echo "<tr>"; echo "<td>create those questions is belong to</td>"; echo "<td>"; echo "<select size=1 name=f>"; include 'config.php'; $sql="select `id`,`content` from question where f=0"; $result=mysql_query($sql); while ($row=mysql_fetch_array($result)) { echo "<option value=".$row["id"]; echo ">".$row[content]; echo "</option>"; } echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>how many question will you want to create</td>"; echo "<td><input type=text name=question_num size=5></td>"; echo "</tr>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=2><center><input type=submit value=next></center></td>"; echo "</tr>"; echo "</form>"; echo "</table>"; echo "fuck"; } else if (!$_POST["question_num"]) { echo "<h2>create question</h2>"; echo "<table border=1>"; echo "<form method=post action=".$_SERVER["PHP_SELF"].">"; $num=$_POST["question_num"]; echo "<input type=hidden name=question_num value=".$num.">"; echo "<input type=hidden name=f value=".$_POST["f"].">"; echo "<tr>"; echo "<td>content</td>"; echo "<td>result</td>"; echo "</tr>"; for ($i=0;$i<$num;$i++) { echo "<tr>"; echo "<td>question".($i+1).":<input type=text name=question[] size=40></td>"; echo "<td>"; echo "<select size=1 name=to[]>"; echo "<option value=0>no<option>"; echo "<option value=1>yes<option>"; echo "</select>"; echo "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td><center><input type=submit value=submit></center></td>"; echo "</tr>"; echo "</form>"; echo "</table>"; } else { $num=$_POST["question_num"]; $f=$_POST["f"]; $sql="insert into question(`f`,`t`,`content`)values"; for ($i=0;$i<$num;$i++) { $content=$_POST["question"][$i]; $t=$_POST["to"][$i]; $sql=$sql."('".$f."','".$t."','".$content."')"; if ($i<$num-1) $sql=$sql.","; } include 'config.php'; $re=mysql_query($sql); if ($re) { echo "create question successful!"; echo "<p>"; echo "click<a href=add_answer.php>here</a>to add answer"; } } echo "<center>"; ?>