change hidden value name in foreach() ???
Posted: Wed Nov 12, 2008 9:13 pm
Code: Select all
if(isset($_REQUEST["Submit"]) == true){
$contactList = "SELECT * FROM contact WHERE client_ID = ('".$_REQUEST["client_ID"]."')";
$db->sql_query($contactList);
$list = $db->sql_fetchrowset();
echo "<form id=\"delContact\" name=\"delContact\" method=\"post\" action=\"\">\r\n";
echo "<table border=1>\r\n";
echo "<tr>\r\n";
echo " <td>Person in Charge</td>\r\n";
echo " <td>Designation</td>\r\n";
echo " <td>Department</td>\r\n";
echo " <td>Main Line</td>\r\n";
echo " <td>Fax Line</td>\r\n";
echo " <td>Direct Line</td>\r\n";
echo " <td>Mobile</td>\r\n";
echo "</tr>\r\n";
foreach($list as $record)
{
echo "<tr>\r\n";
echo " <td>".$record['personIncharge']."\r\n";
echo " <input type='submit' name='EditPIC' value='edit'></td>\r\n";
echo " <input type='hidden' value=".$record['contact_ID']." name='uiuaa'>\r\n";
echo " <td>".$record['designation']."</td>\r\n";
echo " <td>".$record['department']."</td>\r\n";
echo " <td>".$record['mainLine']."</td>\r\n";
echo " <td>".$record['faxLine']."</td>\r\n";
echo " <td>".$record['directLine']."</td>\r\n";
echo " <td>".$record['mobile']."</td>\r\n";
echo " <td><a href='deleteRow.php?id=".$record["contact_ID"]."'>Delete</a></td>\r\n";
echo "</tr>\r\n";
}
echo "</table>\r\n";
}
and it will show into html table using foreach statement
so it will come out like this:
_______________________________________________________________
|Person In charge | designation | department | main line | faxline | mobile|
-------------------------------------------------------------------------
|person1 [edit bttn]| designation1 | dept 1 | 222222 | 222222| 22222|
|person2 [edit bttn]| designation2 | dept 2 | 333333 | 333333|33333 |
| ETC .... (depends on how many i have in mysql table |
--------------------------------------------------------------------------
and if i press the edit button... the text field will be come out liket this:
____________________________________
|___Enter_new_person_in_charge_here ___| [UPDATE BUTTON]
and then i enter new person in charge name and press the update button. so it will update the person in charge name in my database table.
this is the if statement that i've made but its not working .... i dunno how to resolve this problem
Code: Select all
if(isset($_REQUEST["EditPIC"]) == true){
echo "<input name='editPIC' id='editPIC' type='text'>\r\n";
echo " <input type='hidden' value=".$_REQUEST["uiuaa"]." name='uiuaa2'>\r\n";
echo "<input name='submitPIC' id='submitPIC' type='submit' value='update!'>\r\n";
print_r($_REQUEST);
}
if(isset($_REQUEST["submitPIC"]) == true) {
$editPIC = "UPDATE contact SET personIncharge='".$_REQUEST["editPIC"]."' WHERE contact_ID='".$_REQUEST["uiuaa2"]."'";
$db->sql_query($editPIC);
print_r($_REQUEST);
}
so example:
foreach statement show there is 5data from my sql table
and each data contain 1hidden value that i've wrote in foreach statement ... and all hidden value name is the same "uiuaa"
is there anyone can give solution for my problem?
im stuck doing this the whole day