Hello,

I was hoping that someone can help me with this. I have this linking list working, but I have one problem, when I click on the link it shows up with the link like this
winner.php?service=1&&year=2010
and
honorable.php?service=1&&year=2010&award=1

this is for all years not just 2010, and what I need it to do is show

winner.php?service=AM&&year=2010
and
honorable.php?service=AM&&year=2010&award=Notables

I have looked in my db, and the values are correct, so I know that is not the issue.

<ul>
     <?php 
		$row['year']='2010';
	while($row['year']>'2000') {
	?>
    <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 
		} 
		if($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
	  $row['year'] =$row['year'] -1;
	  if ($row['year']=='2000'){
		  break;
	   }
	 }

             ?>
             </ul>

I have not been able to find the solution, I would appreciate any help you can provide.

Thanks,

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.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.