<!-- editarticles.php -->
<HTML>
<HEAD>
<TITLE> Edit article </TITLE>
</HEAD>
<BODY>



<?php
include("articles.inc");
mysql_select_db("petesmc_articles");

if ($submit): // The article's details have
// been updated.

$sql = "UPDATE articles SET " .
"CatID='$catid', " .
"SubID='$subid', " .
"Status='$status', " .
"TID='$tid', " .
"SubTitle='$subtitle', " .
"AuthorID='$authorid', " .
"Description='$description', " .
"Text='$text' " .
"WHERE AID='$aid' AND PID='$pid'";

if (mysql_query($sql)) {
echo("<P>article details updated.</P>");
} else {
echo("<P>Error updating article details: " .
mysql_error() . "</P>");
}

?>

<P><A HREF="articles.php">Return to article list</A></P>

<?php
else: // Allow the user to edit the article
// with ID=$id



$article=mysql_query("SELECT CatID, SubID, Status, TID, SubTitle, AuthorID, Description, Text " .
"FROM articles WHERE AID='$aid' AND PID='$pid' ");

if (!$article) {
echo("<P>Error fetching article details: " .
mysql_error() . "</P>");
exit();
}

$article= mysql_fetch_array($article);

$catid = $article["CatID"];
$subid = $article["SubID"];
$status = $article["Status"];
$tid = $article["TID"];
$subtitle = $article["SubTitle"];
$authorid = $article["AuthorID"];
$description = $article["Description"];
$text = $article["Text"];




?>

<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
<P>Edit ArticleBR>
AuthorID: <INPUT TYPE=TEXT NAME="authorid" SIZE=5 MAXLENGTH=100 value="<?php echo($authorid); ?>"><BR>
TitleID: <INPUT TYPE=TEXT NAME="tid" SIZE=5 MAXLENGTH=100 value="<?php echo($tid); ?>"><BR>
CategoryID: <INPUT TYPE=TEXT NAME="catid" SIZE=5 MAXLENGTH=100 value="<?php echo($catid); ?>"><BR>
SubcategoryID: <INPUT TYPE=TEXT NAME="subid" SIZE=5 MAXLENGTH=100 value="<?php echo($subid); ?>"><BR>
Statusselect name="status" value="<?php echo($status); ?>">
<option value="active">Active</option>
<option value="featured">Featured</option>
<option value="hidden">Hidden</option></select>
SubTitle: <INPUT TYPE=TEXT NAME="subtitle" SIZE=25 MAXLENGTH=100 value="<?php echo($subtitle); ?>"><BR>
Descriptionbr> <TEXTAREA name="description" ROWS=6 COLS=45 WRAP><?php echo($description); ?></textarea><br><br>
Textbr> <TEXTAREA name="text" ROWS=25 COLS=60 WRAP><?php echo($text); ?></textarea><br>
<INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT"></P>
</FORM>

<?php endif; ?>

<table width="100%" border="1"><tr><td><b>Category List/b><br><br>

<?php
// STARRT LISTING

include("articles.inc");
mysql_select_db('petesmc_articles');

$category = mysql_query("SELECT ID, Cat FROM category");
if (!$category) {
echo("<P>Error retrieving categories from database!<BR>".
"Error: " . mysql_error());
exit();
}

while ($cats = mysql_fetch_array($category)) {
$ccatid = $cats["ID"];
$ccat = $cats["Cat"];
echo("$ccatid. $ccat <br>");
}

?>

</td><td><b>SubCategory List/b><br><br>

<?php

include("articles.inc");
mysql_select_db('petesmc_articles');

$subcategory = mysql_query("SELECT ID, CID, SubCat FROM subcategory");
if (!$subcategory) {
echo("<P>Error retrieving subcategories from database!<BR>".
"Error: " . mysql_error());
exit();
}

while ($ssubcats = mysql_fetch_array($subcategory)) {
$ssubid = $ssubcats["ID"];
$ssubcatid = $ssubcats["CID"];
$ssubcat = $ssubcats["SubCat"];
echo("$ssubid - $ssubcatid. $ssubcat <br>");
}

?>

</td><td><b>Authors List/b><br><br>

<?php

include("articles.inc");
mysql_select_db('petesmc_articles');

$authors = mysql_query("SELECT ID, Name FROM authors");
if (!$authors) {
echo("<P>Error retrieving authors from database!<BR>".
"Error: " . mysql_error());
exit();
}

while ($author = mysql_fetch_array($authors)) {
$aauthorid = $author["ID"];
$aauthorname = $author["Name"];
echo("$aauthorid. $aauthorname <br>");
}

?>

</td><td><b>Title List/b><br><br>

<?php

include("articles.inc");
mysql_select_db('petesmc_articles');

$gettitle = mysql_query("SELECT ID, Title FROM title");
if (!$gettitle) {
echo("<P>Error retrieving titles from database!<BR>".
"Error: " . mysql_error());
exit();
}

while ($gottitle = mysql_fetch_array($gettitle)) {
$ttitleid = $gottitle["ID"];
$ttilename = $gottitle["Title"];
echo("$ttitleid. $ttilename <br>");
}

?>
</tr></table>


<!-- END OF LiSTING -->
</BODY>
</HTML>

Any idea why this won't update the table?