Hello,
I have a situation here where I want to a new display page to show only content under a certain ID from sql database. I have something written now and it goes something like this.
I have on my main page a list of articles from many different categories that display in order by most recent. (This is like a blog, I suppose) On the title of the document which is saved in mysql database is under the name ‘title’ i have them echoed from there including the primary key which I named ‘post_id’. I also have it linked so that it is going to a php which will take the ID and use it to search the database for the post_id and then relay the information back on the page.
<h1><a href="fetch.php?id=<?php echo $row_getDisplay['post_id']; ?>"<?php echo $row_getDisplay['title']; ?></a></h1>
This is the link that takes us to the php file.
In my php file it looks like this.
<?php require_once('Connections/XXXXXX.php'); ?>
<?php
if (isset($_GET['id']) == false) // check if id has been set
{
echo "You must select a location"; // if not, display this error
exit;
} else {
$id = (int) $_GET['id'];
if (is_numeric($id) == false)
**{
echo "You must select a valid location.";
} else {**
mysql_select_db($database_XXXXXX, $XXXXXX);
$query = MYSQL_QUERY("SELECT * FROM news WHERE post_id ");
if (MYSQL_NUM_ROWS($query) == "1")
{
$fetch = MYSQL_FETCH_ARRAY($query); // set $fetch to have the values from the table
echo "Title: " . $fetch['title'] . "<BR>"; // output the info
echo "Blog: " . $fetch['blog_entry'] . "<BR>"; // etc...
echo "Author: " . $fetch['author'] . "<BR>"; // etc...
} else {
echo [B]"No match in database found."[/B]; // if no match is found, display this error
}
}
}
?>
What I have in bold is the message I get when I click the title of the link and it takes me to the fetch.php page and displays “No match in database found.” If anyone has a work around for this or maybe can re-write the code so that it can do what I want that would be greatly appreciated. As of now I’m stuck and don’t want to move on until I get it figured out. I might even be doing this the hard way as well. Thanks for the help.