Page 1 of 1

Slideshow, list of slides - 1,2,3 etc - future proof

Posted: Sat Sep 09, 2006 10:56 am
by richo
Hi, i'm doing a slideshow using PHP/MySQL.

I want to have a list of links to skip to certain slides like 1 2 3 4 5
with a link on each one. I know how to do this with a for loop going through the table.

However, if i need to delete the row to get rid of a slide or create an active column and set it to 0, the list ends up looking like this 1 3 4 5.
(if i had made row two inactive)

Here is my current code:

Code: Select all

for ($i=1; $i<=$rowTotal; $i++){
		$row = mysql_fetch_array($result);
		if ($row["active"] == 1){
			echo "<li><a href=\"?slide=" . $row["pkey"] . "\">" . $i . "</a></li>";
		}
	}
How could i maintain the 1,2,3,4,5 list whilst detecting and not displaying the inactive row???

Any ideas or better ways of doing this most welcome!!! please help!

:)

Posted: Sat Sep 09, 2006 11:00 am
by feyd
Add an "else?"

I'm not sure I undestand your problem.

Posted: Sat Sep 09, 2006 11:28 am
by richo
Okay, i'll try and explain better:


At the moment it is displaying:

- 1
- 3
- 4

I have a column in table called "active". If active has the value of "0", that row will not be brought out by the for loop.


The consequence of this is that the list displays as:

- 1
- 3
- 4

instead of:

- 1
- 2
- 3

I know i could probably display something else such as the title of the slide so this wouldn't be a problem. But i unfortunately want is to be a list of numbers.

do you get me!?