0

Hello guys,

<?php 
					include 'dbconnect.php';
					echo 'under profile.php';
					$username=$_SESSION['username'];
					//I think i have to put a query here like "SELECT username FROM accntinfos WHERE username='$username'".  But confused since if I do there would be two queries
$query="SELECT userprofile.profpic FROM userprofile INNER JOIN accntinfos ON accntinfos.accntnum=userprofile.accntnum";
					$result=mysql_query($query, $DBconnect);
					$numrows=mysql_num_rows($result);
					
					
				?>

I have two tables on database ('TABLE1' which contains account informations of USERS, and 'TABLE2' which contains their personal informations). 'TABLE1' columns were 'account numbers' , 'username', and 'passwords', while 'TABLE2' columns were 'account numbers', 'firstname', 'lastname', ... and the rest of personal informations.

My aim is to find the 'lastname' (found on 'table2') of whoever has the account number matched on the 'TABLE1'. So what i did is I used INNER jOIN which you can see on the '$query' variable above.
--NOW WHAT I HAVE TO DO IS TO SEARCH THE USERNAME OF WHOEVER is LOGing IN THE SITE AND RETRIEVE HIS/HER LASTNAME--- but confused of how could to achieve it.

I have JOINED the two but I am stucked up to there. What should be the next step OR, maybe, what should I do before doing the JOIN?. And do I have to use multi query or something?.. pls help and thanks

Edited by bflack: n/a

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by bflack
0

You are almost done, just add column names in the select list you want to access. Your query is alright.

$query="SELECT userprofile.profpic, userprofile.lastname, userprofile.firstname FROM userprofile INNER JOIN accntinfos ON accntinfos.accntnum=userprofile.accntnum";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.