Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inner Join Problem

Status
Not open for further replies.

sd0t1

IS-IT--Management
Mar 14, 2007
131
US
HEllo everyone, i have an inner join Select statement that works great in my sql editor, but when I combine it with the PHP code (a while loop) it comes out NULL.
Does anybody have any ideas why???

Here is the code.

$query = "SELECT DISTINCT program.program_name FROM program INNER JOIN schedule ON program.id = schedule.pid ";
$result = mysql_query($query, $user_login) or die(mysql_error());


while ($row = mysql_fetch_assoc($result));
{
echo $row['program_name'];
}
 
if the query works great in your sql editor, then this is a php question, yes? could you perhaps post it in the php forum?

r937.com | rudy.ca
 
Try to give your select colum a name

$query = "SELECT DISTINCT program.program_name as name FROM program INNER JOIN schedule ON program.id = schedule.pid ";

and then

while ($row = mysql_fetch_assoc($result));
{
echo $row['name'];
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top