Pleas check this query code I can't see what's wrong

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
THEMADGEEK
Forum Newbie
Posts: 21
Joined: Thu Oct 30, 2003 6:04 pm

Pleas check this query code I can't see what's wrong

Post by THEMADGEEK »

Here is a query I am working on that pulls data from 2 different tables and sorts out the results without duplicating the division field. I can't tell what's wrong. Maybe I've been looking at it too long...

Code: Select all

<?
require("includes/connect.inc");

$connection = mysql_connect("$DbHostName", "$DbUserName", "$DbPassWord");

$sql = "SELECT d.div_id, d.div_name, m.first_name, m.last_name, m.divisions FROM divisions as d, members as m WHERE d.div_id IN m.divisions"; (NOTE: m.divisions is a SET field)

$result = @mysql_query($sql,$connection) or die ("Couldn't connect");

$was_division=""; //assuming I don't have empty divisions 

while ($row = mysql_fetch_array($result)) { 

$div_id = $row['div_id'];
$div_name = $row['div_name'];
$full_name = $row['full_name'];

$div_name = $row['div_name'];

   if($row['div_id']!=$was_division) //don't display if already displayed 
   
       @$display_block .= "<p class="title"><b>$div_name</b></p>"; 
	   
   $was_division=$row['div_id']; 

   @$display_block .= "<p class="links">$full_name</p>"; 
} 

?>
Any help would be appreciated!
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

GEEK,

Uhm youre rite....i cant see whats wrong either.....what is wrong by the way????

LOL

Kendall
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

what error message you get?
Post Reply