jperezmt
Mar 11th 2008, 7:12 am
I'm having trouble with this and I don't know what I'm doing wrong.
Here's my code on the first page:
$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 (isset($_REQUEST['update_category'])) {
$update_category = $_REQUEST['update_category'];
$nextpage = $update_category . ".php";
include($nextpage);
}
$query = "SELECT categoryid, category FROM category";
$result = mysql_query($query) or die(mysql_error());
echo "<form action=" . $_SERVER['PHP_SELF'] . " method=\"post\">\n";
echo "<select name=\"categoryid\">\n";
echo "<option>Change Category</option>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$category = $row['category'];
$categoryid = $row['categoryid'];
echo "<option value=\"$categoryid\">" . $category . "</option>\n";
}
echo "</select>\n";
echo "<input type=\"hidden\" name=\"update_category\" value=\"update_category\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\" />\n";
echo "</form>\n";
I used the isset command to call the other page when submitted. Im new to PHP so I didn't know any other way of doing this. Initially I tried it all on one page and the isset was $submit, but that didn't work either.
Here's the second page:
$blogid = $_POST['id'];
$categoryid = $_POST['id'];
$category = $_POST['category'];
$qp1 = "UPDATE blog SET catid = '$categoryid' WHERE blogid = '$blogid'";
$resultqp1 = mysql_query($qp1) or die("shit it don't work");
if ($resultqp1) {
echo "Your blog now has a category, it was posted in " . $category;
echo $resultqp1;
}
Everytime I submit the form the result is always "1". On mySQL the I made the default 1, so that means that there is no category, but it never changes. Anyone know whats wrong.
Here's the site: developer.surefirewebservices.com
Here's my code on the first page:
$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 (isset($_REQUEST['update_category'])) {
$update_category = $_REQUEST['update_category'];
$nextpage = $update_category . ".php";
include($nextpage);
}
$query = "SELECT categoryid, category FROM category";
$result = mysql_query($query) or die(mysql_error());
echo "<form action=" . $_SERVER['PHP_SELF'] . " method=\"post\">\n";
echo "<select name=\"categoryid\">\n";
echo "<option>Change Category</option>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$category = $row['category'];
$categoryid = $row['categoryid'];
echo "<option value=\"$categoryid\">" . $category . "</option>\n";
}
echo "</select>\n";
echo "<input type=\"hidden\" name=\"update_category\" value=\"update_category\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\" />\n";
echo "</form>\n";
I used the isset command to call the other page when submitted. Im new to PHP so I didn't know any other way of doing this. Initially I tried it all on one page and the isset was $submit, but that didn't work either.
Here's the second page:
$blogid = $_POST['id'];
$categoryid = $_POST['id'];
$category = $_POST['category'];
$qp1 = "UPDATE blog SET catid = '$categoryid' WHERE blogid = '$blogid'";
$resultqp1 = mysql_query($qp1) or die("shit it don't work");
if ($resultqp1) {
echo "Your blog now has a category, it was posted in " . $category;
echo $resultqp1;
}
Everytime I submit the form the result is always "1". On mySQL the I made the default 1, so that means that there is no category, but it never changes. Anyone know whats wrong.
Here's the site: developer.surefirewebservices.com