Jump to content

Load more from database


snallemap

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.