While we want to access any variable value we can write
Print $_POST['VariableName']
But it we want to access value for an array variable then what we should write ?
Like for $chk_arr[$i]
How to access this value in some particular function ?
Pls read the code if you are not able to get my point .....
if(isset($_POST['action'])&&$_POST['action']=="Check Feedback")
{
$query="select * from feedback";
$result=mysql_query($query)
or die("Could not execute Query");
$total=mysql_numrows($result);
?>
<INPUT TYPE="hidden" NAME="total" value=<?=$total?>>
<?// Pass the hidden value
if($total>0)
{
print $total;
?>
<TABLE WIDTH="75%" BORDER="5" ALIGN="CENTER" BORDERCOLOR="#000000"
bgcolor="#oo3399" >
<TR BORDERCOLOR="#000000" BGCOLOR="#0099FF" border="0">
<TD><DIV ALIGN="CENTER"><font color="#000000">Check it</DIV></font></TD>
<TD><DIV ALIGN="CENTER"><font color="#000000">Comment
Type</font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font color="#000000">Comment On</font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font color="#000000">Comment</font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font color="#000000">Name</font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font color="#000000">E-mail</font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font color="#000000">Phone</font></DIV></TD>
</TR>
<?
for($i=0; $i<$total; $i++)
{
$row=mysql_fetch_array($result);
?>
<TR BORDERCOLOR="#ffffff" BGCOLOR="#0099FF">
<TD><DIV ALIGN="CENTER"> <input type="checkbox" name="<?
printf("chk_arr[%d]",$i); ?>" value="<?=$row[0]?>" ></DIV></TD>
<TD><DIV ALIGN="CENTER"><font
color="#ffffff"><?=$row[1]?></font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font
color="#ffffff"><?=$row[2]?></font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font
color="#ffffff"><?=$row[3]?></font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font
color="#ffffff"><?=$row[4]?></font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font
color="#ffffff"><?=$row[5]?></font></DIV></TD>
<TD><DIV ALIGN="CENTER"><font
color="#ffffff"><?=$row[6]?></font></DIV></TD>
</TR>
<?
}
print "</TABLE>";
?>
<table width="100%">
<tr align="center">
<td><div align="center">
<input type ="submit" name="submit" style="background-color: #003399;"
style="color: #ffffff;" size="15" length="80" value="Delete" >
</div>
</td>
</tr>
</table>
<?
}
}
if($_POST['submit']=="Delete")
{
Delete_record();
}
function Delete_record()
{
$query="select * from feedback";
$result=mysql_query($query)
or die("Could not execute Query");
print $_POST['total'];
for($i=0; $i<$_POST['total']; $i++)
{
if($_POST['chk_arr[$i]']!=='')
print $_POST['chk_arr[$i]'];
{
$query="delete from feedback where id=$chk_arr[$i]";
$deleteresult=mysql_query($query) or die("Unable to delete". mysql_error();
print $query;
}//if statement
}//for loop
}//Main function Delete_record
Here I am not able to delete records as I am not getting value for $chk_arr[$i].
---------------------------------
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.