2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by sudeepjd
0

That's because you are using a singe "=" operator which is an assign operator rather than a double "==" operator which is an equivalent operator. Change your if statements to

if($row['service']=='AM' && $row['award']=='Winner') {

and

if($row['service']=='AM' && $row['award']=='Notables' || $row['award']=='Honorable Mentions' ) {

then, it should work fine.

Edited by sudeepjd: n/a

0

Hi Sudeepjd,

Thanks for the help, but I tried your suggestion and the entire ul disappeared. When I go and do

if($row['service']=='AM' && $row['award']=='Winner') {

I can't see the winner url, and the same for the honorable. I am stumped, I even tried wrapping this while loop around the entire script.

while($row = mysql_fetch_array($result))
{

}

The problem with this is that it worked but it just made the loop an endless loop.


Thank you,

ADM

That's because you are using a singe "=" operator which is an assign operator rather than a double "==" operator which is an equivalent operator. Change your if statements to

if($row['service']=='AM' && $row['award']=='Winner') {

and

if($row['service']=='AM' && $row['award']=='Notables' || $row['award']=='Honorable Mentions' ) {

then, it should work fine.

0

The ul did not disappear did it? It ended up showing a line of dots on the page, If I'm right.... That was supposed to happen.

Try and add this to the top just after the <?php

$row['service']='AM';
$row['award']='Winner';

This will output the <ul> with a list of years. The years would have the url you are looking for with the service=AM instead of service=1.

There is a problem with your logic though.

1. You need someway to initialize $row to either Winner or Notables or Honorables. This got initiated when you wrapped the whole thing in the while loop
2. You cant have an alternating if statement with $row trying to see "if" it is Winner or Notables. You should try an elseif.

Without looking at your entire code and making some assumptions on what the problem might me I thing this is what you are looking for.

<ul>
	<?php	
	$sql="SELECT * FROM <table> WHERE year>=2000 AND year<=2010 ORDER BY year DESC"; 
	$result=mysql_query($row);
	while($row=mysql_fetch_array($result)){
	?>
		<li>
			<?php if($row['service']=='AM' && $row['award']=='Winner') { ?>
				<a href="winner.php?service=<?php print $row['service'];?>&year=<?php echo $row['year'];?>"><?php echo $row['year'];?></a>
			<?php } elseif($row['service']=='AM' && ($row['award']=='Notables' || $row['award']=='Honorable Mentions')) { ?> 
				| <a href="honorable.php?service=<?php echo $row['service'];?>&year=<?php echo $row['year'];?>&award=<?php echo $row['award'];?>">Honorable Mentions</a>
			<?php } ?>
		</li>
	<?php } ?>
</ul>

Change the <table> above to the name of the table from which you are pulling the data.

The above will work provided you have your table set up with the following columns in it -> year, service, award.

Please let me know how it goes.

Edited by sudeepjd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.