dachshund Posted August 16, 2009 Share Posted August 16, 2009 hi, how can i change this: if($_SESSION['uid']){ $userid = $_SESSION['uid']; $query = "SELECT username FROM users WHERE userid = '$userid'"; $result = mysql_query($query); list($username) = mysql_fetch_row($result); echo "Welcome. \n"; echo $username; }else{ to: $query = "SELECT * FROM users WHERE userid = '$userid'"; so that I can echo something like $rows['email'] as well as $rows['username'] thanks! Quote Link to comment https://forums.phpfreaks.com/topic/170517-solved-echo-from-any-row/ Share on other sites More sharing options...
smerny Posted August 16, 2009 Share Posted August 16, 2009 if($_SESSION['uid']){ $userid = $_SESSION['uid']; $query = "SELECT * FROM users WHERE userid = '$userid'"; $result = mysql_query($query); row = mysql_fetch_assoc($result); echo "Welcome. \n"; echo $row['username']."\n"; echo "Your email is ".$row['email']; }else{ Quote Link to comment https://forums.phpfreaks.com/topic/170517-solved-echo-from-any-row/#findComment-899464 Share on other sites More sharing options...
DrTrans Posted August 16, 2009 Share Posted August 16, 2009 if($_SESSION['uid']){ $userid = $_SESSION['uid']; $query = "SELECT username FROM users WHERE userid = '$userid'"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result) { $username = $row['userid']; $email = $row['email']; echo "Welcome. \n"; echo "$username and $email"; } }else{ Quote Link to comment https://forums.phpfreaks.com/topic/170517-solved-echo-from-any-row/#findComment-899465 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.