ahsesino Posted January 2, 2012 Share Posted January 2, 2012 Hello guys; I posted this thread a couple of days ago in the PHP code section thinking there was something wrong with my php code. So I realized it was in the wrong section, the issue has to be in mysql query. The code is below; when I run the query on "myphpadmin" my result is empty and on the page I want this query to apear the result is a capital S. If someone could help me out I would really appreciate it. <?php $query = ("SELECT nick, avatar_img, person FROM latest_post, profile WHERE latest_post.person = profile.nick AND profile.nick = profile.avatar_img WHERE profile.avatar_img='$avatar_img'"); echo $query[$avatar_img]; ?> Link to comment https://forums.phpfreaks.com/topic/254230-query-issues/ Share on other sites More sharing options...
AyKay47 Posted January 2, 2012 Share Posted January 2, 2012 You are treating $query as an array, where it is a string What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/254230-query-issues/#findComment-1303498 Share on other sites More sharing options...
ahsesino Posted January 3, 2012 Author Share Posted January 3, 2012 Thanks for your reply AyKay47; What Im trying to do is display the current poster avatar next to his post. For that I need to connect to DB and select from two tables three rows. The reason I have to do it this way is because when someone post something new it the new post gets stored in the latest_post table and the avatars are located in the profile table. Tables --------- 1.latest_post 2.profile I need to select "nick","avatar_img" from table "profile" and select "person" FROM table "latest_post" from there I need to make latest_post.person = profile.nick AND make profile.nick = profile.avatar_img to display avatar in box. The reason i use $query is to echo the result. I hope my explanation makes sense. Link to comment https://forums.phpfreaks.com/topic/254230-query-issues/#findComment-1303502 Share on other sites More sharing options...
AyKay47 Posted January 3, 2012 Share Posted January 3, 2012 You are going about this wrong. Take a look at mysql_query and mysql_fetch_arrayfor starters, you will need at least these to display data that your SQL code grabs. Link to comment https://forums.phpfreaks.com/topic/254230-query-issues/#findComment-1303508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.