mattm1712 Posted April 26, 2010 Share Posted April 26, 2010 im new to php so if this is a stupid question just say so i have made a comment system where it just posts commentes into a data base with, my data being username, email , comment and a idnumber say i have a varible $t is post number 120 and a want to get the username from the data base how would i do that? matt Link to comment https://forums.phpfreaks.com/topic/199821-selecting-certain-data-from-database/ Share on other sites More sharing options...
mattm1712 Posted April 26, 2010 Author Share Posted April 26, 2010 what i want to do is make an email notification that replies if someone comments on the post Link to comment https://forums.phpfreaks.com/topic/199821-selecting-certain-data-from-database/#findComment-1048858 Share on other sites More sharing options...
coupe-r Posted April 26, 2010 Share Posted April 26, 2010 try this. $result = mysql_query("SELECT * FROM WHERE id='120'"); $row = mysql_fetch_array($result); $username = $row['username']; echo $username; Link to comment https://forums.phpfreaks.com/topic/199821-selecting-certain-data-from-database/#findComment-1048860 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 Do you know how to use MySQL queries in PHP? If you wanted the username from post 120 you'd use the query SELECT username FROM comments WHERE id = 120 Then in PHP: $result = mysqli_query("SELECT `username` FROM comments WHERE id = 120"); if($result) { $row = mysqli_fetch_assoc($result); $username = $row['username']; } Link to comment https://forums.phpfreaks.com/topic/199821-selecting-certain-data-from-database/#findComment-1048861 Share on other sites More sharing options...
CelticExile Posted April 26, 2010 Share Posted April 26, 2010 SELECT Username FROM tablename WHERE PostNo = $t Link to comment https://forums.phpfreaks.com/topic/199821-selecting-certain-data-from-database/#findComment-1048862 Share on other sites More sharing options...
mattm1712 Posted April 26, 2010 Author Share Posted April 26, 2010 right i want to select the username from the first table then using that usernamr select the email from another table in my database how would that work? Link to comment https://forums.phpfreaks.com/topic/199821-selecting-certain-data-from-database/#findComment-1048878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.