Jump to content

[SOLVED] Get info from specific cell in mysql


ronnie88

Recommended Posts

Hi I wanted to know how I would get info from a specific cell? I've searched the forums with no luck, I know this is a noob question. I thought it would be something like this:

 

$account = mysql_fetch_array(mysql_query("SELECT * FROM adverts WHERE username='$username' AND id='$id'"));

 

but what does all this mean? adverts is the table? The login script I am using is this one:

 

http://www.evolt.org/article/comment/17/60265/index.html

 

Any help would be greatly appreciatied!

@how I would get info from a specific cell?

- what do you mean? you can add a "WHERE " in your query..

- use mysql_fetch_array to get all the matched record in your where clause..

 

i cant find that code in the url you gave..

 

Hi I wanted to know how I would get info from a specific cell? I've searched the forums with no luck, I know this is a noob question. I thought it would be something like this:

 

$account = mysql_fetch_array(mysql_query("SELECT * FROM adverts WHERE username='$username' AND id='$id'"));

 

but what does all this mean? adverts is the table? The login script I am using is this one:

 

http://www.evolt.org/article/comment/17/60265/index.html

 

Any help would be greatly appreciatied!

 

That's poor and sloppy code for querying the database for an entire row(s) from your database where the username and id in the row equal $username and $id and then putting the results into an array $account. Since mysql_fetch_array isn't looped, even if there's more than 1 row returned, $account will only have the first row in the list returned.

 

To access the info returned, you would do for instance

 

echo $account['username']; // echoes the username

echo $account['id']; // echoes the id

echo $account['columnname']; // replace columnname with whatever other column is in your table

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.