Jump to content

why does my people table decide it's empty....grrr *shakes fist*


newbreed65

Recommended Posts

Hi

 

Right I’m currently trying to join my users table with my people table in order to show the name of the last user to update it instead of there numerical value. I just previously did it with my movies table with no issues and the names of the fields and tables are all correct  it’s just when I add the join to the mysql query that it decide that my people table is empty although it was showing all the records before I tried adding the join…..

 

Any idea what may be wrong...If you even get my hyperactive babble lol

 

Here is the code I used with movies which works fine

 

$sql = "SELECT movie.*, users.fullname " .
	"FROM users JOIN movie " .
	"ON (movie.editby=users.user_id) " .
	"ORDER BY ". $order[$ord];

$result = mysql_query($sql) 
  or die(mysql_error()); 

 

 

And here is the code I’ve got for people   

/*this one works fine its just when i add the join

$sql = "SELECT * " .
       "FROM people  ORDER BY ". $order[$ord];  */

$sql = "SELECT people.*, users.fullname " .
	"FROM users JOIN people " .
	"ON (people.lastmodified=users.user_id) " .
	"ORDER BY ". $order[$ord];

$result = mysql_query($sql) 
  or die(mysql_error());

Are there actually records on both tables that are satisfying join criteria (i.e. people.lastmodified=users.user_id )

 

Also, you can write your queries like this

$sql = "SELECT people.*, users.fullname 
      FROM users JOIN people 
      ON (people.lastmodified=users.user_id) 
      ORDER BY {$order[$ord]}";

 

less quotes ;)

Are there actually records on both tables that are satisfying join criteria (i.e. people.lastmodified=users.user_id )

 

Also, you can write your queries like this

$sql = "SELECT people.*, users.fullname 
      FROM users JOIN people 
      ON (people.lastmodified=users.user_id) 
      ORDER BY {$order[$ord]}";

 

less quotes ;)

 

yeah I just didnt realise till my first reply that I had used the wrong field for the people table part of the join

 

thanx about the quotes thing, Ive just been doing that since the book I read did it and phpMyadmin....do you know why they would do it that way?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.