Hi,
I am trying to get something up where by:
-> It dynamically displays input text fields that can be edited.
-> However I need the current id as well as the current value to display
-> when a person submits the form, it updates all / or only each one that has been altered.
Q:
-> I need to use both the id and new value or old value when updating the database. How can this be done?
Code below: of what i have attempted so far.
$sql5 = "SELECT * FROM $tableName";
$functions=array();
foreach ($conn->query($sql5) as $row5) {
$functions[]=<<<END
<input type="hidden" name="row5TextID[]" id="row5TextID[]" value="$row5[id]" />
<input type="text" maxlength="20" value="$row5[page_name]" id="pageName[]" name="pageName[]" onFocus=this.value='' />
Layout Setting: $row5[page_type]
Change setting to:
<select id="layoutSetting" name="layoutSetting" >
<option value="Content">Content</option>
<option value="Gallery">Gallery</option>
<option value="Notes">Notes</option>
</select>
Remove <input type="checkbox" id="remove[]" name="remove[]" value="$row5[id]" />
END;
}
$functions=implode("\r\n",$functions);
if (isset($_POST['saveChanges'])){
foreach($_POST['remove'] as $removed)
$sqlRemove = "DELETE FROM $tableName WHERE id = $removed";
$done = $conn->exec($sqlRemove);
}
if($done) { // Update all the text fields. using the new / old value and the entry id.
foreach($_POST['pageName'] as $pageName) {
$pageNameID = $_POST['row5TextID'];
$sqlUpdate = "UPDATE $tableName SET page_name = $pageName WHERE id = $pageNameID";
$done = $conn->exec($sqlUpdate);
}
}
}
Is there a way to do this?
Thanks for your help