Jump to content


Photo

NewB Question about mysql


  • Please log in to reply
4 replies to this topic

#1 Doomflame

Doomflame
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 24 April 2003 - 12:14 AM

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

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 24 April 2003 - 04:45 AM

[php:1:72eff6ee13]
$result = mysql_query(\"SELECT winner FROM drawings WHERE total = \'1\'\");
$row = mysql_fetch_array($result);
$next = $row[\'winner\'];
[/php:1:72eff6ee13]
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 Doomflame

Doomflame
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 24 April 2003 - 06:28 PM

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\'


#4 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 24 April 2003 - 06:47 PM

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\'];

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#5 Doomflame

Doomflame
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 24 April 2003 - 06:55 PM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users