This is reading the arguement ?edit from the link which is called from a previous page.
Here is the news table structure
aid
int(11)
date
datetime
title
varchar(100)
text
text
ID
int(11) auto_increment
And the users table (Only the fields protaining to this snippet)
id
int(25) auto_increment
first_name
varchar(25)
last_name
varchar(25)
Code: Select all
if (isset($edit)) {
$query = mysql_query("SELECT ID, aid, title, text FROM news WHERE ID='$edit'");
if($query){
while($row = mysql_fetch_array($query)){
$id = $row['ID'];
$aid = $row['aid'];
$title = $row['title'];
$text = $row['text'];
}
} else {
header_valign_center();
msg("There was an error retrieving from the database","");
footer();
exit();
}
$query = mysql_query("SELECT id, first_name, last_name, date FROM users WHERE id='$aid'");
if($query){
while($row = mysql_fetch_array($query)){
$date = $row['date'];
$name = $row['first_name'] . " " . $row['last_name'];
}
} else {
header_valign_center();
msg("There was an error retrieving from the database","");
footer();
exit();
}
header_valign_center();
$news->edit($id, $title, $text, $date, $name);
footer();
exit();
}