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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.