Some of the things look odd cause I thought using $date for example be a conflict, so I changed to $dati, and as a section $news I changed the table name.
Thanks for any help.
adminnews.php (3)
<body bgcolor="white">
<?php
$db = mysql_connect("thingy", "username", "password");
mysql_select_db("dbname",$db);
if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE egonews SET dati='$dati',user='$user',news='$news' WHERE id=$id";
} else {
$sql = "INSERT INTO egonews (dati,user,news,) VALUES ('$dati','$user','$news')";
}
// run SQL against the DB
$result = mysql_query($sql);
echo "Roster updated!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM egonews WHERE id=$id";
$result = mysql_query($sql);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$id) {
// print the list if there is not editing
$result = mysql_query("SELECT * FROM egonews",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a> \n", $PHP_SELF, $myrow["id"], $myrow["dati"], $myrow["user"]);
printf("<a href=\"%s?id=%s&delete=yes\">(DELETE)</a><br>", $PHP_SELF, $myrow["id"]);
}
}
?>
<P>
<a href="<?php echo $PHP_SELF?>">ADD A RECORD</a>
<P>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($id) {
// editing so select a record
$sql = "SELECT * FROM egonews WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["id"];
$dati = $myrow["dati"];
$user = $myrow["user"];
$news = $myrow["news"];
// print the id for editing
?>
<input type=hidden name="id" value="<?php echo $id ?>">
<?php
}
?>
<font color="white">dati name:<input type="Text" name="dati" value="<?php echo $dati ?>"><br>
user name:<input type="Text" name="user" value="<?php echo $user ?>"><br>
news:<input type="Text" name="news" value="<?php echo $news ?>"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
?>
</body>
news.php (3)
<body bgcolor="black" background="http://www.eliteguard.co.uk/images/emplogo.jpg" text="white">
<?php
$db = mysql_connect("thingy", "username", "password");
mysql_select_db("dbname",$db);
$result = mysql_query("SELECT * FROM egonews",$db);
?>
<table align=center width=500 height=100 bgcolor=black>
<tr><td align=center><font size=5 color=green>Elite Guard News</font></td></tr>
<?php
do {
printf ("
<tr><td>%s %s</td></tr>
<tr><td><font size=4>%s</font></td>\n",
$myrow["dati"], $myrow["user"], $myrow["news"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table>\n";
?>
</body>
They can be located as below.
<a href="http://cgi.jamescaddy.plus.com/cgi-bin/adminnews.php">Adminnews.php</a>
<a href="http://cgi.jamescaddy.plus.com/cgi-bin/news.php">news.php</a>