PDA

View Full Version : Storing columns in variables using PHP


Tjk
12-05-2005, 05:43 PM
Is this the correct way to store variables from a mysql row...?


<?
$row= mysql_query("SELECT * FROM data WHERE userid='$userid'") or die("Could not select data from table data");
while(mysql_query($row){
$name= $row['name'];
$dob= $row['dateofbirth'];
}
?>

Is there a better way of doing it?

TheShaner
12-05-2005, 06:10 PM
Yes, there are many ways to do this which are much better (esp. since your code doesn't work :p ).

http://www.php-mysql-tutorial.com/php-mysql-select.php

This tutorial lists a bunch of ways to retrieve rows from a query.

-Shane