PHP retrieve data from table row and store to variable

$getinfo = "select user_firstname, user_middlename, user_lastname from tempuserinfo where user_email ='$ead' and activation_code='$eac'";
$query = mysql_query($getinfo, $db);

while ($row = mysql_fetch_array($query)) {
    $firstname = $row['user_firstname'];
    $lastname = $row['user_lastname'];
}
 
If you are only getting one row back (make sure you add a LIMIT to your SQL statement), then you can use something like this:


$getinfo = "select user_firstname, user_middlename, user_lastname from tempuserinfo where user_email ='$ead' and activation_code='$eac'"; 
$query = mysql_query($getinfo, $db); 
$row = mysql_fetch_array($query); 
$firstname = $row['user_firstname']; 
$lastname = $row['user_lastname'];
 

Comments

Popular posts from this blog

Script For Login, Logout and View Using PHP, MySQL and Bootstrap

Hyperledger Development with in 10 days — Day 6

Insert CheckBox and Radio button Data in MySQL Database Using PHP