OK. I have done some PHP and even scripted a few things myself but I've had to learn PHP through books and just plain old doing it so I'm not the best but I seem to do fine with everything but arrays. So I have this page I'm working on that will be a simple scheduling page. Everything is laid out in an HTML table and each table cell contains this code:
if ($container[1] != NULL) {
echo "$container[1]";
} else {
echo "<input type='text' name='name' size='20'><br><input type='hidden' name='add' value='go'><input type='hidden' name='block' value='p1'><INPUT TYPE='image' SRC='res.jpg' HEIGHT='17' WIDTH='100' BORDER='0' ALT='Submit Form'>";
}
The only thing that changes between one cell to the next is the number in brackets in $container[x]. So the code in the next cell would be:
if ($container[2] != NULL) {
echo "$container[2]";
} else {
echo "<input type='text' name='name' size='20'><br><input type='hidden' name='add' value='go'><input type='hidden' name='block' value='p1'><INPUT TYPE='image' SRC='res.jpg' HEIGHT='17' WIDTH='100' BORDER='0' ALT='Submit Form'>";
}
When you type text into the form field and submit it it gets added to the mysql db in the proper place but when the page refreshes there's still a form field and submit button in the cell instead of the text. The conditional is failing and I'm sure it has something to do with how I'm trying to use the array fetched from the db, I'm not too good with arrays. This is my call to the mysql db to fetch data, also the script that sends data to the db which works fine:
<?php
if ($add == "go")
{
$connection = mysql_connect(localhost, username, password) or die("couldn't connect to the database");
$db = mysql_select_db(db_name, $connection);
$sql = "UPDATE monday SET name='$name' WHERE block='$block'";
$result = mysql_query($sql, $connection) or die("Can't Access DB<br>$sql");
}
$connection = mysql_connect(localhost, username, password) or die("Couldn't Connect to the Database");
$db = mysql_select_db(dn_name, $connection);
$sql = "select * from monday";
$result = mysql_query($sql,$connection);
$container = mysql_fetch_array($result);
Any ideas what I'm messing up here?