Jump to content

Weird?


40esp

Recommended Posts

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

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

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.