i have created a table to store a random number in and now i need the number that has been stored in the db to equal a variable on the new page.

to get the information out of the db i have used this code

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

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

if i wanted the data in the row to set the variable to equl the same number would i write at the bottom instead of of the echo

$rand={$row['random1']};

once the result from the mysql query has been set to be the value of the variable $rand would this then be available for use throughout this page?

the code i have used does set the value of the variable to equal the number that is stored in the db.

would this variable then be able to be used in other parts of the page to then display the variable or is this only available to the mysql query. If i not being clear enough please say and i will try to explain better what i mean.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.