checkbox validation / PHP array function
Posted: Wed Oct 07, 2009 6:47 am
Hi guyz,
I am back with a new problem....
Problem : When I check one checkbox & click UPDATE, page move to Update.php with one field (to be updated).
But even after checking 2 checkboxes, page is posting 2 values to update.php but showing one field only.....
http://localhost/test/update.php?id=48&id=49
posting the values but action is not done
I want the same number of fields to be shown, which are checkboxed on edit page.
Hope I clear the issue...
Please check attach images also....
I have 2 pages edit.php and update.php
Edit page contain the value from database repeated with checkbox, update delete button using while loop..
Code for Edit page
and Update page have input field with passed value and update button
Code for update page :
I am back with a new problem....
Problem : When I check one checkbox & click UPDATE, page move to Update.php with one field (to be updated).
But even after checking 2 checkboxes, page is posting 2 values to update.php but showing one field only.....
http://localhost/test/update.php?id=48&id=49
posting the values but action is not done
I want the same number of fields to be shown, which are checkboxed on edit page.
Hope I clear the issue...
Please check attach images also....
I have 2 pages edit.php and update.php
Edit page contain the value from database repeated with checkbox, update delete button using while loop..
Code for Edit page
Code: Select all
<?php
$con = mysql_connect("xxxxx","xxx","xxxxxxxxx");
$db = mysql_select_db("test",$con);
$select = mysql_query("select * from test_tbl");
?>
<form name="editForm" action="delete.php" method="GET">
<table border='0' cellpadding='4' cellspacing='0' align='center' width='100%'>
<tr bgcolor="#24a1b6">
<td> </td>
<td colspan="3">Location</td>
</tr>
<?php
while($result = mysql_fetch_array($select))
{
$id = $result['id'];
$location = $result['location'];
echo "<tr>
<td><input type='checkbox' name='id' value='$id'></td>
<td>$location</td>
<td align='center'><input type='submit' value='Delete'></td>
<td align='right'><input type='Submit' value='Update' onclick=\"document.editForm.action='update.php'; return true;\"></td>
</tr>";
}
?>
</table>
</form>
Code for update page :
Code: Select all
<?php
$con = mysql_connect("xxxxx","xxx","xxxxxxxxx");
$db = mysql_select_db("test",$con);
$new_id = $_GET['id'];
$update = mysql_query("select * from test_tbl WHERE id='$new_id'");
?>
<html>
<head>
<title>Update Page</title>
</head>
<body>
<form action="updateaction.php" method="get" name="EditAddForm">
<table border="0" cellpadding="4" cellspacing="0" align="center" width="100%">
<tr bgcolor="#24a1b6" class="whitetext">
<td width="28%">Location</td>
</tr>
<tr>
<td height="5" colspan="8"></td>
</tr>
<?php
while($uresult = mysql_fetch_array($update))
{
$id = $uresult['id'];
$location = $uresult['location'];
echo "<tr>
<input type='hidden' name='id' value='$id'>
<td><input type='text' name='new_location' value='$location' size='45' maxlength='50'></td>
<td align='center'><input type='submit' value='Update'></td>
</tr>";
}
?>
</table>
</form>
</body>
</html>