Find jobs - Article directory - Boxing Class - Rome hotels - Debt Consolidation

PDA

View Full Version : Want to pull random info from database and display it randomly on page.


Doug the Great
Nov 20th 2007, 10:42 pm
Hello everyone, i'm going to try and explain this to the best of my knowledge.

I run an arcade site and I get a bunch of featured request.

http://www.GameFrat.com

As you can see I have 8 featured games in the featured section (top horizontal). But I want to be able to add more than 8 and the php will pull any 8 from the collection of featured games. I already made a table in my DB called "featured" with 3 fields "Name, Game URL, Thumbnail". I wanna be able to add the info here, display it in html format exactly like I have it now at the top.

Can someone right me a mock up please so all I have to do is add Game Name / GameURL.html / Thumbnail.jpg

and it will display in a <a href="$game_url"><img src="/images/$thumbnail">$game_name</a> format and it will only display 8 games.

Thanks!
Doug

serialCoder
Nov 20th 2007, 10:47 pm
hi, i am not really sure on what you want done, is it the form that you want done or the script to pull the random data from the db?

Doug the Great
Nov 20th 2007, 11:00 pm
hi, i am not really sure on what you want done, is it the form that you want done or the script to pull the random data from the db?

Well I want the data to be pulled and 8 different games being displayed, and upon refresh 8 new games appear. http://www.BootyArcade.com see there top 8 featured games?

serialCoder
Nov 20th 2007, 11:02 pm
well, you can probably use Mysql's random() function

ex: SELECT * FROM tableName ORDER BY RAND() LIMIT 8

Doug the Great
Nov 20th 2007, 11:11 pm
well, you can probably use Mysql's random() function

ex: SELECT * FROM tableName ORDER BY RAND() LIMIT 8

Well I have that but i'm very new at this and that's all I got

<?PHP
$rs = mysql_query("SELECT Name AS feat_name, URL AS feat_url, Thumbnail AS feat_thumb from featured ORDER BY RAND() LIMIT 1");
while (list ($feat_name, $feat_url, $feat_thumb) = @mysql_fetch_row($result3));
{"<A href=''>$feat_name</a>";
}
?>

serialCoder
Nov 20th 2007, 11:17 pm
please try this...


<?PHP
$rs = mysql_query("SELECT Name AS feat_name, URL AS feat_url, Thumbnail AS feat_thumb from featured ORDER BY RAND() LIMIT 8");
while($row = mysql_fetch_assoc($rs)
{
echo '<A href="'.$row['feat_url'].'"><img src="'.$row['feat_thumb'].'"></a>";
}

?>

it will output the thumbnail with a link, i'm not sure where to put the name though

Doug the Great
Nov 20th 2007, 11:29 pm
please try this...


<?PHP
$rs = mysql_query("SELECT Name AS feat_name, URL AS feat_url, Thumbnail AS feat_thumb from featured ORDER BY RAND() LIMIT 8");
while($row = mysql_fetch_assoc($rs)
{
echo '<A href="'.$row['feat_url'].'"><img src="'.$row['feat_thumb'].'"></a>";
}

?>

it will output the thumbnail with a link, i'm not sure where to put the name though

Parse error: parse error, unexpected '{' in /home/content/u/p/l/uploadstand/html/test.php on line 8

serialCoder
Nov 20th 2007, 11:34 pm
oh, darn its hard to write code in the editor :rolleyes:

after </a> just change the double quote " into a single quote '

Doug the Great
Nov 20th 2007, 11:44 pm
Thanks for the help serialCODER, I got it now.

<?PHP
$q=mysql_query("SELECT Name AS feat_name, URL AS feat_url, Thumbnail AS feat_thumb FROM `featured` ORDER BY RAND() ASC LIMIT 8");
while ($line=mysql_fetch_assoc($q)) {
echo "<td>";
echo "<a href=\"$line[feat_url]\"><img src=\"$line[feat_thumb]\" />$line[feat_name]</a>";
echo "</td>";
}


?>

serialCoder
Nov 20th 2007, 11:58 pm
always glad to be of any help :)

if you have projects that would require extensive coding, i am available :D