Jump to content

mysql db help


kev wood

Recommended Posts

i want to run a query on a mysql db that i have set up but when it returns the results i want it give a variable the same value as the query.  i am storing a random number in a db to use with images when they are displayed so that the image does not show the cached version of the image when the page is loaded again.

 

i have got the query to work with the echo function so i know that the number is being stored.  i now need to know how to give a variable the same value as the stored number the code i am using is this

 

$query = "SELECT random1 FROM random_number";
$result=mysql_query($query);

while($row=mysql_fetch_array($result)){
$rand="{$row['random1']}";

 

it is the lst line that i am unsure about i do not know if this is giving the variable a value at all?

Link to comment
Share on other sites

it does give the variable a value but will this then be available to use around the rest of the page or is it only available to use with the mysql query.  i not i not sounding clear but i is trying to explain myself.

 

i want to be able to append this number to the end of image file as it has been stored on the server with this number appended to the file.  as it is a randomly generated number the only way i can think of being able to use it again is by storing it in a db when generated and then retrieving it again when the image needs to be viewed again.

 

it may be a stupid question but i have never used the results from a mysql query in this way before.

Link to comment
Share on other sites

Guest
This topic is now 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.