40esp Posted May 30, 2008 Share Posted May 30, 2008 I have this code: <?php mysql_select_db($database_sw, $sw); $query_group_filter = sprintf("SELECT * FROM practice_groups WHERE group_id = %s", GetSQLValueString($colname_group_filter, "int")); $group_filter = mysql_query($query_group_filter, $sw) or die(mysql_error()); $row_group_filter = mysql_fetch_assoc($group_filter); $totalRows_group_filter = mysql_num_rows($group_filter); ?> <?php do { ?> <?php $practice_id_var = $_GET['practice_group_id']; if ($row_group_filter['group_id'] == $practice_id_var) { echo ">"; } ?><a href="link"/>Link</a><br /> <?php } while ($row_practice_groups = mysql_fetch_assoc($practice_groups)); ?> What im doing is looping through all records, and I want it to check if the group_filter = the GET variable. Im doing this so I can put a marker in my navigation so the user knows what link they are at. The problem is, Every link has a marker in front of it. The marker is the ">". What am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/107904-weird/ Share on other sites More sharing options...
monkeypaw201 Posted May 30, 2008 Share Posted May 30, 2008 where is it getting the `group_id` from? i see $colname_group_filter, but not where it is defined.. Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553117 Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 group_id is a column in my table. Its retrieving the group_id column field value from mysql. Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553121 Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 it might also help to mention im filtering the data with the same GET variable. Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553122 Share on other sites More sharing options...
monkeypaw201 Posted May 30, 2008 Share Posted May 30, 2008 WHERE group_id = %s", GetSQLValueString($colname_group_filter, "int")); right there... where is $colname_group_filter being defined? Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553125 Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 $colname_group_filter = "-1"; if (isset($_GET['practice_group_id'])) { $colname_group_filter = $_GET['practice_group_id']; } here Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553145 Share on other sites More sharing options...
The Little Guy Posted May 30, 2008 Share Posted May 30, 2008 if ($row_group_filter['group_id'] == $practice_id_var) { echo ">"; } ?><a href="link"/>Link</a><br /> to if ($row_group_filter['group_id'] == $practice_id_var) { echo ">"; } ?><a href="link"/>Link</a><br /> Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553154 Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 didnt work Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553158 Share on other sites More sharing options...
The Little Guy Posted May 30, 2008 Share Posted May 30, 2008 $query_group_filter = sprintf("SELECT * FROM practice_groups WHERE group_id = %s", mysql_real_escape_string($colname_group_filter)); Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553162 Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 that didnt work neither. Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553165 Share on other sites More sharing options...
The Little Guy Posted May 30, 2008 Share Posted May 30, 2008 are you getting bad output, or what is happening? basically what are you expecting to get and what are you currently getting? Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553166 Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 The if statement isn't working, its applying the ">" to everything being displayed in the loop. Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553167 Share on other sites More sharing options...
The Little Guy Posted May 30, 2008 Share Posted May 30, 2008 First off, I don't think you should use a do-while Second, you need to set $colname_group_filter Give this a try: mysql_select_db($database_sw, $sw); $colname_group_filter = 'some value'; $query_group_filter = sprintf("SELECT * FROM practice_groups WHERE group_id = %s", mysql_real_escape_string($colname_group_filter)); $group_filter = mysql_query($query_group_filter, $sw) or die(mysql_error()); $row_group_filter = mysql_fetch_assoc($group_filter); $totalRows_group_filter = mysql_num_rows($group_filter); while($row_practice_groups = mysql_fetch_array($practice_groups)){ $practice_id_var = $_GET['practice_group_id']; if ($row_group_filter['group_id'] == $practice_id_var) { echo ">"; } echo '<a href="link"/>Link</a><br />'; } Link to comment https://forums.phpfreaks.com/topic/107904-weird/#findComment-553169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.