Jump to content

Archived

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

Doomflame

NewB Question about mysql

Recommended Posts

I am connected to the database fine, but please give me the code to store the result of the query below in the variable $next.

 

SELECT winner FROM drawings WHERE total = \'1\'

 

Thanks,

The NewBie

Share this post


Link to post
Share on other sites

[php:1:72eff6ee13]

$result = mysql_query(\"SELECT winner FROM drawings WHERE total = \'1\'\");

$row = mysql_fetch_array($result);

$next = $row[\'winner\'];

[/php:1:72eff6ee13]

Share this post


Link to post
Share on other sites

Thanks!

 

How would I make it handle this code if the output will be more than one value for each?

 

SELECT name, owner, value, shares FROM stocks WHERE owner = \'$username\'

Share this post


Link to post
Share on other sites

same way as said

 

$result = mysql_query("SELECT name, owner, value, shares FROM stocks WHERE owner = \'$username\'"); 

$row = mysql_fetch_array($result); 

$na= $row[\'name\']; 

$ow = $row[\'owner\'];

$va = $row[\'value\'];

$sh = $row[\'shares\'];

Share this post


Link to post
Share on other sites

No, I mean if it should fetch 5 names, values, and shares....

 

How would I store them in arrays like this:

 


$name = array("name1", "name2", "name3", "name4", "name5")

$values = array("value1", "value2", "value3", "value4", "value5")

$shares = array("shares1", "shares2", "shares3", "shares4", "shares5")



replacing ___1-5 with the fetched value.

Share this post


Link to post
Share on other sites

×

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.