Hi All,
I am going to need a plug-in that would perform a database query on the products table in mysql db, and select a random product record. The plug-in would then assign the random record to a Smarty array. If you know about Pinnacle Cart, that's what I use for my shopping cart.
This is what I have come up with so far...However, I am lost with Smarty, so bare with me...
PHP Code:
<?
// Connect to the database
mysql_connect ('localhost', 'user', 'pasword') ;
mysql_select_db ('dbname');
// Edit this number to however many links you want displaying
$num_displayed = 1 ;
// Select random rows from the database
$result = mysql_query ("SELECT * FROM links 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=\"" . $row["link"] . "\">
<img src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;
}
?>
Note: By the time this code is finished, it should display a random product that I can include in my html file using: {include file="nameoftemplate.html"}
Ps: The reason this code won't 'fully compy' with my cart, is because my cart uses the Smarty Template Engine...
Please Respond As Soon As Possible
TIA
-Brian
Last edited by Brian07002 : 05-04-2005 at 05:18 PM.
|