I located a JS script and its a simple image rotator. I am trying to get a php script to read from the database which row in the table 'table1' column 'featured' has a 1 in it which means its a featured category. With this info in hand, i want it to then read the rows from table 'table2' all the rows which have the same 'cat_id' as the featured 'cat_id'. Table 1 and 2 both have 'cat_id'.
Okay with those i will now have a few rows from table2 that have the same cat_id as that of the row in table1 which category is featured. With this i need to read the url field of the ROWS(there will always be multiple rows) from table two which have been selected. Then i need to get this into a javascript script. This is where i get stuck.
Here is my code so far
Code: Select all
<?php
$getcat = mysql_query("SELECT * from ccms_screenshots_cat WHERE featured='yes'");
while($row5 = mysql_fetch_assoc($getcat))
$theimage=$row5[cat_id];
$getimg = mysql_query("SELECT * from ccms_screenshots WHERE cat_id='$theimage'");
while($row6 = mysql_fetch_assoc($getimg))
{
echo "</br>";
echo $row6[url];
}
?>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
url="URL GOES HERE";
alt="ALT TEXT";
banner="IMAGE URL HERE";
width="NUMBER";
height="NUMBER";
}
if (ad==2) {
url="URL GOES HERE";
alt="ALT TEXT";
banner="IMAGE URL HERE";
width="NUMBER";
height="NUMBER";
}
if (ad==3) {
url="URL GOES HERE";
alt="ALT TEXT";
banner="IMAGE URL HERE";
width="NUMBER";
height="NUMBER";
}
if (ad==4) {
url="URL GOES HERE";
alt="ALT TEXT";
banner="IMAGE URL HERE";
width="NUMBER";
height="NUMBER";
}
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0></a>');
// End -->
</SCRIPT>Im echoing the urls just now just so i know the scripts okay. What im stuck at is how to get each of the 4 located rows and get the url's into each of the url="URL GOES HERE" in the javascript.
how would i go about doing that?
Regards