ronnie88 Posted July 23, 2008 Share Posted July 23, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/116111-solved-get-info-from-specific-cell-in-mysql/ Share on other sites More sharing options...
unkwntech Posted July 23, 2008 Share Posted July 23, 2008 What sql portion (SELECT * FROM advets WHERE username='...) of this says is: Give me all the information from the table adverts where the username field is equal to $username and the id field is equal to $id. Quote Link to comment https://forums.phpfreaks.com/topic/116111-solved-get-info-from-specific-cell-in-mysql/#findComment-597072 Share on other sites More sharing options...
vbnullchar Posted July 23, 2008 Share Posted July 23, 2008 @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.. Quote Link to comment https://forums.phpfreaks.com/topic/116111-solved-get-info-from-specific-cell-in-mysql/#findComment-597080 Share on other sites More sharing options...
ronnie88 Posted July 23, 2008 Author Share Posted July 23, 2008 I found this on the forums only thing I could find suitable i'll keep giving a whack at it the code is at the url its the whole page.. Quote Link to comment https://forums.phpfreaks.com/topic/116111-solved-get-info-from-specific-cell-in-mysql/#findComment-597084 Share on other sites More sharing options...
.josh Posted July 23, 2008 Share Posted July 23, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/116111-solved-get-info-from-specific-cell-in-mysql/#findComment-597116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.