So... I have a 2 Table (mysql) Db. Table 1 = (sub)Menu, Table 2 = Images per (sub)Menu.
Typical scenario - new.php - loads a form with a MENU ADD form, and a List of current Menus (with Edit and Delete).
Edit loads Edit.php, with MENU Edit form (id got from new.php) which lists items per menu_id (T2, images). The row values, (not id's/ pks) are output in TEXT boxes
- and My question is how can I make these editable text-box, EDITABLE in their list view, so I can Update on the same page?
edit.php
...
...
Code:
$result = mysql_query("SELECT * FROM `images` WHERE `imageMenu_id` = '$id' ORDER BY image_position ASC") or trigger_error(mysql_error());
while($row = mysql_fetch_array($result)){
foreach($row AS $key => $value) {
$row[$key] = stripslashes($value);
}
// While - - Do this once for each... ie create row...
echo "<form name ='add_update' action='' method='POST'>";
echo "<tr>";
echo "<td valign='top'>" . nl2br( $row['image_id']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['imageMenu_id']) . "</td>";
echo "<td valign='top'><input type='text' name='image_name' value='" .stripslashes($row['image_name']) ."'/></td>";
echo "<td valign='top'><input type='text' name='image_position' value='" .stripslashes($row['image_position']) ."'/></td>";
echo "<td valign='top'><input type='text' name='image_file' value='" .stripslashes($row['image_file']) ."'/></td>";
echo "<td valign='top'><input type='submit' value='Update Image' /><input type='hidden' value='1' name='submbit_update' />";
echo "</tr>";
echo "</form>";
}
echo "</table>";
...
...
I had been trying along the lines of this, but I cant grab the individual row id...
...
edit.php
...
Code:
if (isset($_POST['submbit_update'])) {
$sql = "UPDATE `images` SET `image_name`= '{$_POST['image_name']}', `image_position`= '{$_POST['image_position']}', `image_file`= '{$_POST['image_file']}'
WHERE `image_id` = '$????????'"; // $IMAGEid - cant grab this per UPDATE BUTTON (not link, and many on page)
mysql_query($sql) or die(mysql_error());
echo (mysql_affected_rows()) ? "Edited row. " : "Nothing changed. ";
}
Key to this is not requiring another page, as I have the T1 list on new.php and the T2 (per T1 id) list in edit.php.
Note: - The edit.php for T2 (images) will always display all rows per the Menu_Id on Update - and not load to an Edit with just that row.
(I would then issue a Row changed message - which is fine!)
Possibly a slightly trickier one, but I'll remain hopeful someone could suggest some refined direction/ suggestions...
Many thanks
(see images:
http://www.phpfreaks.com/forums/inde...tml#msg1320785)