Jump to content

Getting a single value from a result


cliftonbazaar

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).

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

Archived

This topic is now archived and is closed to further replies.

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