我正在尝试将我的表单值添加到我的数据库中,但我收到类似未定义索引的错误:在第 120 行提交一些代码是,
<?php
echo "</tr></table></form>";
$conn = mysql_connect('localhost','root','');
mysql_select_db('itcompanylist',$conn);
$result = mysql_query("SELECT state_name FROM `states` WHERE c_id =1");
$i = 0;
echo "<form method='post' action=''><table border='1' ><tr>";
while ($row = mysql_fetch_row($result)){
// echo "<td><a href='#' onclick='someFunction()'>" .$row['0']. "</a> </td>";
echo '<td><input type="submit" name="submit" value="'.$row['0'].'"></td>';
if ($i++ == 2)
{
echo "</tr><tr>";
$i=0;
}
}
echo "</tr></table></form>";
?>
动作在同一页面上触发,页面在下面,当动作触发到页面时,我遇到错误:未定义的索引:在第 120 行提交
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("itcompanylist");
$query = "SELECT s_id FROM states WHERE `state_name` = '".$_POST['submit']."'";
$result1 = mysql_query($query);
$row = mysql_fetch_array($result1);
$result2 = mysql_query("SELECT city_name FROM `city` WHERE s_id ='".$row['s_id']."'");
$i = 0;
echo "<form method='post' action='demo2.php'><table border='1' ><tr>";
while ($row = mysql_fetch_row($result2)){
echo '<td><input type="submit" name="ok" value="'.$row['0'].'"></td>';
}
echo "</tr></table></form>";
?>