求大神看看这个关于创建问题的代码
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phperror_reporting(E_ALL & ~ E_NOTICE);echo "";if (!$_POST["question_num"]){ echo "<h2>create question</h2>"; echo "<table border="1">"; echo ""; echo "<tr>"; echo "<td>create those questions is belong to</td>"; echo "<td>"; echo ""; include 'config.php'; $sql="select `id`,`content` from question where f=0"; $result=mysql_query($sql); while ($row=mysql_fetch_array($result)) { echo "".$row[content]; echo ""; } echo ""; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>how many question will you want to create</td>"; echo "<td></td>"; echo "</tr>"; echo "</tr>"; echo "<tr>"; echo "<td colspan="2"></td>"; echo "</tr>"; echo ""; echo "</table>"; echo "fuck";}else if (!$_POST["question_num"]){ echo "<h2>create question</h2>"; echo "<table border="1">"; echo ""; $num=$_POST["question_num"]; echo ""; echo ""; 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).":</td>"; echo "<td>"; echo ""; echo "no"; echo "yes"; echo ""; echo "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td></td>"; echo "</tr>"; echo ""; 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!"; e<strong style="color:transparent">9来源gaodai#ma#com搞@代~码$网</strong>搞gaodaima代码cho "<p>"; echo "clickhereto add answer"; }}echo "";?>
数据库方面没有问题,就是我输入问题个数点击下一步的时候,就直接转到下一个添加答案的页面去了…本来应该实现的是,查询question,如果有问题数量没有问题内容时候,进入else if那里面,执行循环创建问题…为什么一直进去不呢..求大神指教指教..
——解决方案——————–