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 Quote Link to comment 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 Quote Link to comment 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; Quote Link to comment 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']; } Quote Link to comment Share on other sites More sharing options...
CelticExile Posted April 26, 2010 Share Posted April 26, 2010 SELECT Username FROM tablename WHERE PostNo = $t Quote Link to comment 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? Quote Link to comment 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.