hi, i'm really new to programming in general, and i think i've figured out how to insert and select data from mysql databases, however, i can't seem to get values from a table and work on it
here, i'm trying to
1) grab a number from my table
2) generate a random number in javascript, which i add onto the number i grabbed
3) update the table value to this new number
<?php
$con = mysql_connect("","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("databasename", $con);
$result = mysql_query("SELECT num FROM number WHERE key=1");
while($row = mysql_fetch_array($result))
{
echo ("var num=$row['num']");
}
<script>
var ran=Math.floor(Math.random()*11)
number1=num+ran
document.write(number1);
</script>
mysql_select_db("databasename", $con);
mysql_query("UPDATE number SET num=number1,
WHERE key=1");
mysql_close($con);
?>
the table has 2 rows, "key" so that i know which number i'm using ( in this case key=1) and num, which is the number that gets worked on
i guess i'm having issues with passing values back and forth from different languages.
thanks in advance!