Re: dynamic content again

From: Date: Fri, 09 Mar 2001 19:16:50 +0000
Subject: Re: dynamic content again
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43211@lists.php.net to get a copy of this message
here is an example. <?php $database_db = 'bookmarks'; include_once('database_class.egn'); $HOW_MANY = 10; if (!isset($pos)) $pos = 0; $pos_prev = $pos - $HOW_MANY; $pos_next = $pos + $HOW_MANY; $product_count = $database->count('site', ''); $result = $database->select_array('', 'site', "LIMIT $pos, $HOW_MANY"); foreach($result as $pos => $val) echo $val['site_address'] ."<br>\n"; if ($pos_prev >= 0) echo " <a href='$PHP_SELF?pos=$pos_prev'>Back</a> "; echo " <a href='$PHP_SELF?pos=0'>Home</a> "; if ( $pos_next < $product_count ) echo " <a href='$PHP_SELF?pos=$pos_next'>Next</a> "; ?> compare your position to how many fields are in the db. SELECT count(*) FROM site ; -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 lee@mediawaveonline.com ""george"" <chiefmonkey@wisemonkeydesign.co.uk> wrote in message news:98b7n0$mfc$1@toye.p.sourceforge.net... First of all thanks to everyone who has helped me from this ng but I am afraid I have another question I am using the code below to pull FAQ out of a database but how do I stop the next link appearing when the last question is displayed TIA george if ( !isset( $start )){ $start = 0; } $num_q = 4; $sql =" SELECT DISTINCT * FROM $table_name LIMIT $start, $num_q"; $start += 4; $newStart = $start - $num_q; $result = @mysql_query($sql, $connection) or die ("Couldnt execute query"); while ($row = mysql_fetch_array($result)) { echo "<tr><td class=\"headline\">$row[headline]</td></tr><tr><td align=left class=\"answer\">$row[answer]</td ></tr>"; } echo "</table>"; ?></td> </tr> <tr> <td colspan="2"><a href="<? print "$PHP_SELF?newstart=$start? - $num_q" ; ?>">Previous</a> <a href="<? print "$PHP_SELF?start=$start"; ?>">Next</a></td> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#43211) next »