Jump to content

Quote Database link


fridgefreezer

Recommended Posts

Hey, I just wondered if someone could help me with this small problem?

 

Here's the code:

 

<?php
if($_GET['act'] == "generate_quotes") {

$db = mysql_connect("*", "*", "*") or die ("Unable to connect to database.");
mysql_select_db("quote") or die ("Unable to select database.");

$offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `quote` ");
$offset_row = mysql_fetch_object( $offset_result ); 
$offset = $offset_row->offset;
$result = mysql_query( " SELECT * FROM `quote` LIMIT $offset, 1 " );
$fetch = mysql_fetch_array($result); 


echo "<blockquote>".$fetch['q_quote'];
mysql_close($db);

} else { 

echo "<img src=\"1.png\">";

}
?>


<a href='gen.php?act=generate_quotes'>Generate</a>

 

Basically what it does is shows an image until a link is clicked, then the image disappears and some quotes are generated in it's place.

 

When you click the link, sure enough, the image disappears and the quotes are read from the database. But after that the link doesn't change the quote. [it's meant to randomly cycle through the quotes in the database].

 

The quote still changes when refreshing the page, but this link:

 

<a href='gen.php?act=generate_quotes'>Generate</a>

 

does nothing after 'generate_quotes' has been set.

 

any ideas how to fix this?

 

thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/209205-quote-database-link/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.