Here's my HTML code (which is actually created with a PHP loop):
PHP Code:
...
<center>
<form method="post" action="events_save.php">
<table>
<?
include("config.php");
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
$query = "SELECT chron, date, details FROM $table3";
$result = mysql_query($query);
$variable = mysql_fetch_row($result);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<tr>
<td><input name=\"date{$row['num']}\" size=\"2\" type=\"text\" value=\"{$row['date']}\"> </td>
<td><textarea cols=\"30\" rows=\"5\" name=\"det{$row['num']}\" size=\"300\">{$row['details']}</textarea></td>
</tr>";
}
?>
</table>
<input type="submit" value="Save">
</form>
</center>
</body>
</html>
Here's my unfinished PHP:
PHP Code:
<?
include("config.php");
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
// VARIABLES?!?!
for ($num = 1; $num <= 13; $num=$num+1) {
$sql = "UPDATE events SET date='', details='' WHERE chron=$num";
mysql_query($sql) or die("Changes could not be saved. Please use the 'BACK' button and try again.");
}
echo "Changes Saved"
?>
I am trying to make some sort of loop that will change the value of SET 'date' and 'det' so I can have the respective content (1 through 13) inserted into the table. Does that make sense?
I can obviously use the loop to change the value of $num which changes the row that the content is inserted to, but how can I change the CONTENT itself to each of the POSTED values upon each run through the loop?
Thank you very much!
Bookmarks