Jump to content

Getting a single value from a result


cliftonbazaar
 Share

Recommended Posts

Hi,

 

If my table is

Batman  Human  45

Superman Alien  33

 

How do I display Superman's race and age?

 

Currently I have

$sql_statement = "SELECT * FROM heroes";
$toons=mysqli_query($mysql_DB, $sql_statement);

while($toons = mysqli_fetch_array($results, MYSQLI_ASSOC)) {
echo name;
}

 But this shows all the results where I only want one.  Yes I know I could do a "WHERE name = Superman" in the statement but I want the whole table loaded in as I wish to use the other name (Batman) in another part of the program.

Please note that this is only a sample data table, the real table is a lot bigger (42k rows so I can't simply do a new sql call each time).

Edited by cliftonbazaar
Link to comment
Share on other sites

I have no idea what you're trying to do there. First you want one record, then you want two records, and then you talk about loading 42,000 records all at once, which sounds rather insane.

 

Forget about SQL for now and give us the full picture. What do you want to do with what information? How is the resulting page supposed to look like?

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

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.

 Share

×
×
  • 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.