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? Quote Link to comment 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.. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 /> Quote Link to comment Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 didnt work Quote Link to comment 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)); Quote Link to comment Share on other sites More sharing options...
40esp Posted May 30, 2008 Author Share Posted May 30, 2008 that didnt work neither. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 />'; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.