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?

...

$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...

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
			mysql_query($sql) or die(mysql_error()); 
			echo (mysql_affected_rows()) ? "Edited row.   " : "Nothing changed.   "; 
			//echo "<a href='new.php'>Back To Listing</a>";
		}

Key to this is not requiring another page, as I have the T1 list on new and the T2 (per T1 id) list in edit.php

Possibly a slightly trickier one, but I'll remain hopeful someone could suggest some refined direction/ suggestions...

Many thanks
(attached images new & edit, per browser)

<a href='add_update,php?act=edit?imageid='.stripslashes($row['image_id'].'><input type='image' value='Update Image' /></a>

if (isset($_POST['submbit_update'])) {  
        if($act='edit'){
            $sql = "UPDATE `images` SET `image_name`= '{$_POST['image_name']}', `image_position`= '{$_POST['image_position']}', `image_file`= '{$_POST['image_file']}'
                WHERE `image_id` = '$_Request['imageid']'"; // $IMAGEid - cant grab this per UPDATE BUTTON
            mysql_query($sql) or die(mysql_error()); 
            echo (mysql_affected_rows()) ? "Edited row.   " : "Nothing changed.   "; 
            //echo "<a href='new.php'>Back To Listing</a>";
        }}

try this one hope it will help you.

<a href='add_update,php?act=edit?imageid='.stripslashes($row['image_id'].'><input type='image' value='Update Image' /></a>

?

and... above line has 9 ' (I was sure these worked in pairs??? In fact I think this is a fundamental).

plus... I am working (or trying to work) with:

<input type='submit' value='Update Image' /><input type='hidden' value='1' name='submbit_update' />

With respect, perhaps someone with some good knowledge could point my code in the right direction - outlined at top.

Many, many thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.