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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.