Web Hosting Talk







View Full Version : calling a stored value - mysql


BlueyBlue
06-05-2005, 01:41 AM
Hi :)

I am trying to creat additional features for AlphaOrder and am a little stuck.

The mysql db is queried and gets all the data for the user, but how do i call for vairables..

Ie,

fname = john
lname = smith

(that was in the db)

Now the script wont call those values, any idea what to do?


$query="SELECT * FROM clients WHERE username='$username' AND password='$password' ";

Thats how i call the all the data on a user.

Anyone with an idea?

orbitz
06-05-2005, 01:53 AM
you can see some examples for using 2 different functions to solve your problem:

http://us3.php.net/manual/en/function.mysql-fetch-row.php

http://us3.php.net/mysql_fetch_assoc

sojish
06-05-2005, 11:47 AM
Like orbitz said .. u can use mysql_fetch_array for it .

$result = mysql_query("SELECT id, name FROM mytable");

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("ID: %s Name: %s", $row["id"], $row["name"]);
}


Btw , whats the "AlphaOrder" all about ?
You have given the features ... but still , In one sentence whats it all about ?

Nyture
06-05-2005, 12:36 PM
$query = mysql_query("SELECT fname,lname FROM clients WHERE username='$username' AND password='$password'");

list($fname,$lname) = mysql_fetch_row($query);

echo $fname;
echo $lname;


enjoy ^.^

innova
06-06-2005, 12:13 AM
Also check out the extract() function if you would like to further simplify your variable names.