Need help with writing PHP to file
Posted 12 September 2006 - 03:47 PM
<?php $imgad_num = rand(1, $num); ?>
The $num of course will be replaced with a number before it's sent out, so the writing will be:
<?php $imgad_num = rand(1, ; ?>
Something like that.
Can I put this in a var?
Posted 12 September 2006 - 04:11 PM
It random. 1 - whatever numbers of banners there are in the database. Right now I have 7, so its 1, 7. But if I add another one I want PHP to make it to 8 and so on.
Posted 12 September 2006 - 04:15 PM
That will work. I'll test it and see how it goes.
Posted 13 September 2006 - 04:43 PM
$sql = "SELECT * FROM banners ORDER BY ASC"; // Make sure you change banners to your table name. $resultofmysql_query = mysql_query($sql); $count = mysql_num_rows($resultofmysql_query); // the result variable should be the mysql query string that gets all rows from database $randomnumber = rand(1,$count); // This will generate a random number between 1 and the total number of rows.<br>
I think this should work pretty simple someone correct me if I made a mistake please, want to make sure I'm giving accurate advice. =)
<b>Trust the TechnoLust</b>
<b><u>Have a question check here:</u></b>
PHP Manual: http://www.php.net
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users