Php 设置了Post变量,但显示未定义的索引错误
我想从MySQL数据库中选择一行,其中有多行 我选择了单选按钮进行选择,并将该行的id放入单选按钮值中 问题是设置了posted单选按钮,当IPhp 设置了Post变量,但显示未定义的索引错误,php,mysql,undefined-index,Php,Mysql,Undefined Index,我想从MySQL数据库中选择一行,其中有多行 我选择了单选按钮进行选择,并将该行的id放入单选按钮值中 问题是设置了posted单选按钮,当Iecho时,正如您在代码中看到的那样,它会显示正确的id 当我想使用MySQL查询从数据库中进行选择时,它会给我一个未定义的错误,奇怪的是当我选择一个只包含一行的表时,这段代码正在工作,但当行数超过一行时,我无法选择所选行 表代码: <? if($_SESSION["count"]!=0 || $_SESSION["count"]!="") { ?&
echo
时,正如您在代码中看到的那样,它会显示正确的id
当我想使用MySQL查询从数据库中进行选择时,它会给我一个未定义的错误,奇怪的是当我选择一个只包含一行的表时,这段代码正在工作,但当行数超过一行时,我无法选择所选行
表代码:
<?
if($_SESSION["count"]!=0 || $_SESSION["count"]!="")
{
?>
<!-- begining of levels informations -->
<form name="form2" method="POST" dir="rtl" action="" style="font-family:'B_yekan';">
<div align="center" width="900" >
<table class="styled-table" cellspacing="0" width="900" border="1">
<tr>
<th width="10" scope="col" ></th>
<th width="60" scope="col">level</th>
<th width="60" scope="col">date</th>
<th width="60" scope="col">time</th>
<th width="54" scope="col">price</th>
<th width="60" scope="col">mark</th>
</tr>
<?php
$id = array();
while($rows=mysql_fetch_array($result)){
$id[]=$rows['id'];
?>
<tr>
<td><input class="styled-input" type="hidden" name="id[]" id="id" value= "<? echo $rows['id']; ?>" /></td>
<td><input class="styled-input" type="text" name="lev" id="lev" value="<? echo $tbl_name; ?>" /></td>
<td><input class="styled-input" type="text" name="date[]" id="date" value="<? if($rows['date']=="1"){echo "even";}else{echo "odd";}?>" /></td>
<td><input class="styled-input" type="text" name="time[]" id="time"
value="<?if($rows['time']=="pm1"){ echo"16 - 17:30";}
elseif($rows['time']=="pm2"){ echo "17:45 - 19:15";}
elseif($rows['time']=="pm3"){echo "19:30 - 21";}?>" />
</td>
<td><input class="styled-input" type="text" name="price[]" id="price" value= "<? echo $rows['price']; ?>" /></td>
<td><input class="styled-input" style="padding: 5px;width:20px" type="radio" name="mark[]" id="mark" value="<? echo $rows['id']; ?>" /></td>
</tr>
<?php
}//end of loop
?>
</table>
</div>
<input class="styled-button-8" type="Submit" value="firstchoose" name="firstchoose" />
<?}//end of if check for count?>
</form>
水平
日期
时间
价格
做记号
发布您收到的完整错误消息,并执行print\r($\u REQUEST['mark'])
并发布结果。同时发布第二个文件的完整代码,当前代码不包含连接行etc@Prix谢谢你的提示,我把mark[]改成了mark,问题解决了。所有代码都在一页中,因为表单操作中没有设置任何内容。@mohammadhosseini
<!-- first choose level -->
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['firstchoose']) && $_POST['firstchoose'] == 'firstchoose')
{
$tbl_name=$_POST['lev'];
for($i=0;$i<$_SESSION["count"];$i++)
{
$checked =mysql_real_escape_string($_REQUEST['mark'][$i]);
echo $checked;
$sql2="SELECT * FROM $tbl_name WHERE `id`='".mysql_real_escape_string($checked)."' ";
$result2=mysql_query($sql2);
$data = mysql_fetch_assoc($result2);
$count2=mysql_num_rows($result2);
}
if(isset($result2)){
?>
<script language="javascript">alert('the level is selected successfully.'); </script>
<?php
}
}
?>
<!-- end of first choose level -->