snallemap Posted September 23, 2010 Share Posted September 23, 2010 This is the code im using: <?php include "config.php"; if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $sql = "SELECT email FROM gusers WHERE id = $id LIMIT 1"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); echo "Email: " . $row['email']; } } } I am trying to get more informations than just the e-mail address, but everytime it seems to fail, i am a completly newb to php but ill try my best.... Could someone tell how this is done properly (like loading name, info, and so on from the database and showing it aswell) Link to comment https://forums.phpfreaks.com/topic/214202-load-more-from-database/ Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 I've tried some more and i just cant seem to make it work Please anyone? Link to comment https://forums.phpfreaks.com/topic/214202-load-more-from-database/#findComment-1114584 Share on other sites More sharing options...
Miss_Rebelx Posted September 23, 2010 Share Posted September 23, 2010 What is it not doing correctly? / What is it doing? What should it be doing? You don't need to put in all those if statements. Try something like this: <?php include "config.php"; if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $sql = "SELECT email FROM gusers WHERE id = $id LIMIT 1"; $result = mysql_query($sql) or die (mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); echo "Email: " . $row['email']; } } Link to comment https://forums.phpfreaks.com/topic/214202-load-more-from-database/#findComment-1114591 Share on other sites More sharing options...
merylvingien Posted September 23, 2010 Share Posted September 23, 2010 SELECT email FROM should be either SELECT email, nextcollumn, anothercollumn, etc FROM Or, if you want to pull all the collumns from the database: SELECT * FROM Then just echo each row as you want it: echo "Email: " . $row['email'] . "and" . $row['nextcollumn']; etc Link to comment https://forums.phpfreaks.com/topic/214202-load-more-from-database/#findComment-1114594 Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 Thanks alot ill try it out right away Link to comment https://forums.phpfreaks.com/topic/214202-load-more-from-database/#findComment-1114600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.