Hi Chrishirst,
I've tried what you supplied me with but I couldn't get it working so, I've done some checking in my database at the structure, and this is what I can tell you.
All I need to do is SELECT a ROW (fieldname) from two different tables and use them both in the following script. One ROW (fieldname) from the catalog table is called: cid and one from ROW from the products table is called: pid
Here's the original script again:
Code:
<?
// Connect to the database
mysql_connect ('localhost', 'user', 'pass') ;
mysql_select_db ('db_name');
// Edit this number to however many links you want displaying
$num_displayed = 1 ;
$category = '165' ;
// Select random rows from the database
$result = mysql_query ("SELECT * FROM products WHERE cid=$category ORDER BY RAND() LIMIT $num_displayed");
// For all the rows that you selected
while ($row = mysql_fetch_array($result))
{
// Display them to the screen...
echo "<a href=\"http://www.sample.com/index.php?p=product&id=" . $row["pid"] ."&parent=" . $row["cid"] . "\"> <img src=\"displaythumb.php?image=" . $row["image_url"] . "\" border=1 alt=\"" . $row["title"] . "\">
<br>
$row[title]
</a>" ;
}
?>
One thing I forget to mention was that in the above SELECT statement from where the WHERE statement begins, I need that as is so that it reads cid=$category, but it doesn't seem to work as is because the cid ROW (fieldname) doesn't exist in the products table as the script currently states. The cid ROW (fieldname) exists in the catalog table NOT the products table. But I DO need the products table to get the actual image, and the catalog table to get the category in which that product exists in.
The url part of the script (at the very bottom of the above code) needs to be changed so that the part that says: . $row["pid"] is from the products table & . $row["cid"] is from the catalog table.
Hope you understand this time.
Thanks again!
-Brian
__________________
Made2Own
Last edited by Brian07002; 12-29-2005 at 04:08 PM..
|