smokinjoe Posted December 13, 2007 Share Posted December 13, 2007 First of all, Hello i have 2 tables im working with table a= groups table b= groups_friends when a user goues to his groups it is supposed to pull the groups he has joined from groups_friends by his member id and group_id then get all the info on those from the groups table. the problem is that it keeps pulling the table id from groups_friends and not the group id from groups so the link to the group is wrong. function display_joined_groups($member_id, $n) { $group=new groups; // paging $n=$n-1; $n_next=$n+20; $sql="select count(*) as a from groups a, group_friends b where a.id = b.group_id and b.member_id = $member_id"; $result=mysql_query($sql); $data_set=mysql_fetch_array($result); print mysql_error(); if($data_set["a"]<=$n_next) { $next=0; } else { $next=1; } $sql="select * from groups a, group_friends b where a.id = b.group_id and b.member_id = $member_id and a.hidden_group = '0' order by a.group_name desc limit $n, 20"; $result=mysql_query($sql); print mysql_error(); //print mysql_num_rows($result); //print $sql; // paging // Start Displaying $sr_no=1; while($data_set=mysql_fetch_array($result)) { if($sr_no%5==0) { print "</tr><tr valign=top>"; } print "<td><table cellSpacing=0 cellPadding=0 width='100%' bgColor='#ffffff' border='0'>"; print "<tbody><tr vAlign=top><td height=117><table cellSpacing=0 cellPadding=5 width='100%' border=0>"; print "<tbody><tr align=middle><td vAlign=top align=middle width=68 bgColor=#ffffff>"; print "<table cellSpacing=0 align=center border=0><tbody><tr><td vAlign=top align=middle>"; // Group Name print "<a href='view_group.php?group_id=$data_set[id]'>$data_set[group_name]</a></td></tr>"; print "<tr><td vAlign=top align=middle><a href='view_group.php?group_id=$data_set[id]'>"; $num_images=$group->get_group_num_images($data_set["id"]); if($num_images==0) { print "<img height=75 alt='' src='images/no_pic.gif' width=75 border=0></A>"; } else { $image_url=$group->get_group_image($data_set["id"]); print "<img height=75 alt='' src='$image_url' width=75 border=0></A>"; } $group_creator=$group->get_member_id($data_set["id"]); if($group_creator==$member_id) { print "<br><img src='images/mod.bmp'>"; } print "</td></tr></tbody></table></td></tr></table></table>"; $sr_no=$sr_no+1; } // paging print "<tr><td width='100%' colspan='4' class='content'>"; if($n!=0) { $n_previous=$n-20; print "» <a href='my_groups.php?n=$n_previous'>Previous</a>"; } if($next==1) { print " » <a href='my_groups.php?n=$n_next'>Next</a>"; } print "</td></tr>"; // paging } Link to comment https://forums.phpfreaks.com/topic/81532-solved-pullung-wrong-data-from-table/ Share on other sites More sharing options...
fenway Posted December 14, 2007 Share Posted December 14, 2007 You asked for *, it's going to give you everything...? Link to comment https://forums.phpfreaks.com/topic/81532-solved-pullung-wrong-data-from-table/#findComment-414446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.