I need help!!!
I'm trying to create a blog app and I want to add categories for my blog post. The only thing is when I set up the code, it is not updating the category id.
Here is my code
PHP Code:
<?php
/* add the query in order for this to work i.e. qry = SELECT table FROM ....*/
$query = "SELECT blogid, title, date, blogentry, blog.catid, category.categoryid, category.category FROM blog INNER JOIN category ON blog.catid = category.categoryid ORDER BY blogid DESC LIMIT 1";
$result = mysql_query($query) or die(mysql_error());
$row=mysql_fetch_array($result, MYSQL_ASSOC);
$blogid = $row['blogid'];
$categoryid = $row['categoryid'];
$catid = $row['catid'];
$category = $row['category'];
$text = $row['blogentry'];
$title = $row['title'];
$date = $row['date'];
echo "<b>" . $date . "</b><br />\n ";
if (!$catid == 1) {
echo "Posted in " . $category . "<br />";
} else {
if (isset($submit)) {
$qp1 = "UPDATE blog SET catid = '$categoryid' WHERE blogid = '$blogid'";
$resultqp1 = mysql_query($qp1) or die("shit it don't work");
}
$query = "SELECT categoryid, category FROM category WHERE categoryid > 0";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$categoryid = $row['categoryid'];
$category = $row['category'];
echo "<form action=" . $_SERVER['PHP_SELF'] . " method=\"post\">\n";
echo "<select name=\"category\">\n";
echo "<option>Change Category</option>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$category = $row['category'];
echo "<option>" . $category . "</option>\n";
}
echo "</select>\n";
echo "<input type=\"hidden\" name=\"categoryid\" value=\"$categoryid\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\" />\n";
echo "</form>\n";
}
echo "<h3><a href=\"blog.php?id=$blogid\">$title</a></h3><br />\n";
// assuming the words are separated by spaces
$text_array = explode(' ', $text);
for($x = 0; $x < 300; $x++){
echo $text_array[$x] . ' ';
}
echo "... <a href=\"blog.php?id=$blogid\">read more</a>";
?>
Anybody know what I could be doing wrong?? Any suggestions??