Ok, you should put SQL statements in all CAPITALS. Like so:
SELECT... FROM... WHERE.
Field names should have ticks : `column_1`
So let's edit your code... :
First we have to fix the INSERT INTO statement. You've written it as an UPDATE statement, so that's why it won't work. Here's how it should be:
PHP Code:
<?php
require_once('config.inc.php');
if(isset($_POST[s1]))
{
$main = $_POST['MainPage'];
$about = $_POST['AboutUs'];
$q1 = "INSERT INTO name_table (MainPage, AboutUs)
VALUES('$main','$about')";
mysql_query($q1) or die(mysql_error());
echo "<br><center>News added successfully!</center><br>";
?>
I assumed you have two fields called MainPage and AboutUs and we don't really need the ticks here.
$_POST[] variables should also have single quotes around them:
PHP Code:
$_POST['variable'];
Now for the other code:
PHP Code:
<?php
require_once('config.inc.php');
//get the current settings
$q1 = "SELECT * FROM $table_name ORDER BY `id` DESC";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
while($a1 = mysql_fetch_array($r1)) {
echo $a1['MainPage'] . '<br />';
}
?>
Once you've got the array you want to echo the MainPage for each row.
This should sort it out. Just say if you have any more problems.
Bookmarks