Hi,
I have this problem that i dont know how to work out as im still very new to php/sql. I have a script that queries my database and pulls out information about a blog entry ( title, body text, author, date submitted). All this info is generated from one table ( and yes the author column is creating redundant data but ill sort that out soon)
I have another table in my db thats for categories. My first query gets the category id fine and assigns it to a variable ($cat). Now the problem question i have is how to incorportae the query ive made below. Can i include it somehow in the query above and do both at once or what? ive never made a call to two databases in the same instance before.
Could anyone suggest a good way to do this? As the code is now all thats getting printed out( in green) is resource1d#4???!?!?!
PHP Code:<ul>
<?php
require_once ('mysql_connect.php'); // Connect to the db.
$sql = "SELECT * FROM entries ORDER BY date_submitted DESC LIMIT 5";
$query = mysql_query($sql);
echo $query;
while ($row = mysql_fetch_array($query)) {
$title = $row['title'];
$body = $row['body'];
$author = $row['author_id'];
$date = $row['date_submitted'];
$cat = $row['category_id'];
?>
<li><?php echo $title; echo $date; echo $body; ?></li>
<p style="red"><?php echo $author; ?></p>
<p style="color: red;"><?php echo $cat; ?></p>
<?php
}
?>
<?php
$sql = "SELECT category FROM categories Where categories.category_id = $cat";
$result = mysql_query($sql);
?>
</ul>
<p style="color: green;"><?php echo $result; ?>
</p>








Bookmarks