ruleitho
06-06-2006, 04:18 PM
PHP definatly isn't my stong point, so i was wondering if anyone could help me with this...
file1.php
<?PHP
// Database Details
$host = "localhost";
$database = "**********";
$user = "*********";
$password = "******";
// MySql Connection
$connection = mysql_connect($host,$user,$password)
or die ("$Error1");
$db = mysql_select_db($database,$connection)
or die ("$Error2");
// Error Messages
$Error1 = "Sorry No Information Available [Error: 1]"; // Check Database Host, Username and Password
$Error2 = "Sorry No Information Available [Error: 2]"; // Check Database Name
$Error3 = "Sorry No Information Available [Error: 3]"; // Unable to Execute Query for Today
$day = date("Y-m-d", mktime(0,0,0, date(m), date(d)-1,date(Y)));
// Queries
$detail_query = "SELECT id,date,detail FROM specialoffers WHERE date>'$day' LIMIT 30";
// Query and Database
$result = mysql_query($detail_query)
or die ("ERROR 111");
echo "<form method='POST' action='process.php'>\n";
echo "<p> </p>";
echo "<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='476'>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr>\n
<td width='150' align='center'>$date</td> \n
<td width='288'>\n
<p align='center'><textarea rows='6' name='$date' cols='27'>$detail</textarea></td>\n
</tr>\n";
}
echo " </table>
<p> </p>
<p><input type='submit' value='Submit'><input type='reset' value='Reset' name='B2'></p>
</form>";
?>
process.php
...
$date = trim($date);
$query = "UPDATE specialoffers SET detail='$date' WHERE date='$date'";
$results = mysql_query($query)
or die ("Couldn't Update Information...");
?>
Database Structre
id | _date__ | ____detail ____ |
1 | 2006-1-1 | blah blah blah xc|
2 | 2006-1-2 | blah blah blahad |
3 | 2006-1-3 | blah blah sablah |
4 | 2006-1-4 | blah blahae blah |
5 | 2006-1-5 | blah blahad blah |
...
file1.php displays 30 records from the database, the first record being todays date. The results are displayed so the detail appears in a text box so it can be altered and updated in the database.
process.php is ment to update the information in the database, however it's not working. I get no error, but the database isn't updating. Can you take a look at the code and see where i'm going wrong...
file1.php
<?PHP
// Database Details
$host = "localhost";
$database = "**********";
$user = "*********";
$password = "******";
// MySql Connection
$connection = mysql_connect($host,$user,$password)
or die ("$Error1");
$db = mysql_select_db($database,$connection)
or die ("$Error2");
// Error Messages
$Error1 = "Sorry No Information Available [Error: 1]"; // Check Database Host, Username and Password
$Error2 = "Sorry No Information Available [Error: 2]"; // Check Database Name
$Error3 = "Sorry No Information Available [Error: 3]"; // Unable to Execute Query for Today
$day = date("Y-m-d", mktime(0,0,0, date(m), date(d)-1,date(Y)));
// Queries
$detail_query = "SELECT id,date,detail FROM specialoffers WHERE date>'$day' LIMIT 30";
// Query and Database
$result = mysql_query($detail_query)
or die ("ERROR 111");
echo "<form method='POST' action='process.php'>\n";
echo "<p> </p>";
echo "<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='476'>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr>\n
<td width='150' align='center'>$date</td> \n
<td width='288'>\n
<p align='center'><textarea rows='6' name='$date' cols='27'>$detail</textarea></td>\n
</tr>\n";
}
echo " </table>
<p> </p>
<p><input type='submit' value='Submit'><input type='reset' value='Reset' name='B2'></p>
</form>";
?>
process.php
...
$date = trim($date);
$query = "UPDATE specialoffers SET detail='$date' WHERE date='$date'";
$results = mysql_query($query)
or die ("Couldn't Update Information...");
?>
Database Structre
id | _date__ | ____detail ____ |
1 | 2006-1-1 | blah blah blah xc|
2 | 2006-1-2 | blah blah blahad |
3 | 2006-1-3 | blah blah sablah |
4 | 2006-1-4 | blah blahae blah |
5 | 2006-1-5 | blah blahad blah |
...
file1.php displays 30 records from the database, the first record being todays date. The results are displayed so the detail appears in a text box so it can be altered and updated in the database.
process.php is ment to update the information in the database, however it's not working. I get no error, but the database isn't updating. Can you take a look at the code and see where i'm going wrong...
