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

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

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

Post 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!

:)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Add an "else?"

I'm not sure I undestand your problem.
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

Post 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!?
Post Reply