I have this code I have put together. It retrieves records and shows them in the table just fine. I need to be able to change the info in the table and update the DB. I found this code for updating multiple rows in a tutorial. I cannot get it to work. Here is the code in its entirety:
[php]
Edit TemplateCQ Simple Phone Provisioning System -- Template Edit
Template to edit:
$link = mysql_connect(“localhost”, “root”, “XXXX”) or die (‘Error connecting to mysql’ . mysql_error());
mysql_select_db(“cqadmin”);
$sql2 = “SELECT id,templatename,keyname,keyid,keytype,keyvalue,keylabel from cqadmin.keys where templatename = ‘$tempname’;”;
$result2 = mysql_query($sql2) or die(mysql_error());
echo "
Keys | Type | Templatename | Key ID | Key type id | Key value | Key label | Id | <input type=‘text’ name=‘keyname[]’ value=’” . $row[‘keyname’] . "’ readonly> | “; “; while($rowA = mysql_fetch_assoc($result)) { echo ‘’ . $rowA[‘keyname’] . ‘’; } echo “ |
<input type=‘text’ name=‘templatename[]’ value=’” . $row[‘templatename’] . “’> | ”;<input type=‘text’ name=‘keyid[]’ value=’” . $row[‘keyid’] . “’> | ”;<input type=‘text’ name=‘keytype[]’ value=’” . $row[‘keytype’] . “’> | ”;<input type=‘text’ name=‘keyvalue[]’ value=’” . $row[‘keyvalue’] . “’> | ”;<input type=‘text’ name=‘keylabel[]’ value=’” . $row[‘keylabel’] . “’> | ”;<input type=‘text’ name=‘id[]’ value=’” . $row[‘id’] . “’> | ”;
---|
// Count table rows
$count=mysql_num_rows($result2);
echo $count;
// Check if button name “Submit” is active, do this
if($Submit){
for($i=0;$i<$count;$i++){
$sql3=“UPDATE keys SET templatename=’$templatename[$i]’, keyname=’$keyname[$i]’, keyid=’$keyid[$i],‘keytype=’$keytype[$i]’,keyvalue=’$keyvalue[$i]’,keylabel=’$keylabel[$i]’ WHERE id=’$id[$i]’”;
$result3=mysql_query($sql3);
}
}
if($result1){
header(“location:droptest.php”);
}
mysql_close();
?>
[/php]
The last bit for the Submit button is the code I got from the tutorial. When I hit the submit I get an error saying there is an unexpected > in line 57. I can’t see the difference in that line and the ones above it.
I really appreciate any ideas that you guys can offer. I know the code is messy. I am just a hack here so far.
Thanks again