Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-08-22, 03:39 AM
Junior Member
 
Join Date: Aug 2005
Posts: 2
BlackIbanez
Default

Hello everybody.. I've been trying to put together a simple news script. This is what I have in my index.php.
I'm having trouble with the Pages: part of the script.
It shows me how many pages are in total (ex: Pages: 1 2) however when I click on 2, it doesn't take me to the other 5 posts.

Can somebody debug it for me?
I would really appreciate your help. Thanx. Here's the code:

Code:
<? echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>"; 
 	$query = mysql_query("SELECT Id, date, title, post FROM news ORDER BY Id desc LIMIT 5") or die(mysql_error()); 
 	$newsnum = 0;
 	while($var = mysql_fetch_array($query)) { 
  $Id = $var['Id']; 
  $date = $var['date']; 
  $title = $var['title'];
  $post = $var['post']; 
  $newsnum++;
  echo "<tr><td align='center'><table width='100%' border='0' cellpadding='1' cellspacing='2' class='newstop'>
  <tr> 
     <td><span class='font-orange'><b>$date</b></font><span class='font-white2'> | <b>$title</b></span></td>
    </tr>
  	</table>
  	<table width='100%' height='42' border='0' cellpadding='0' cellspacing='2' class='newsnews'>
    <tr> 
     <td height='38' valign='top'><span class='font-white'>$post</font><br> <table width='100%' border='0' cellspacing='0' cellpadding='0'>
  	
   	<tr> 
     <td height='12'></td>
   	</tr>
    </table></td>
    </tr>
  	</table>
  	</td></tr><tr><td height='5'></td></tr>";
    }
 	echo "</table>";
 	$ttnum =1;
 	$totnum = $newsnum / 5 + 1;
 	echo "<span class='font-orange'>Pages:</span> ";
 	while ($ttnum <= $totnum){ 
 	echo "<b><a href=\"index.php?id=$newsnum&faqe=$ttnum\"><span class='font-white2'>$ttnum</span></a></b>";	
 	$ttnum ++;}
?>
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2005-08-22, 09:29 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

change your SQL for the limit statement to accept the $_GET[faqe] value.

limit $_GET[faqe],5
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2005-08-22, 09:59 AM
Junior Member
 
Join Date: Aug 2005
Posts: 2
BlackIbanez
Default

Hey Xnuiem, thanx for your support...
Well, I have only 4 rows on my news table in the database: Id, date, title, post...
Do I need another row for faqe?

I'm also getting this error in
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '5' at line 1"

This is the line that is causing the error...
$query = mysql_query("SELECT Id, date, title, post FROM news ORDER BY Id desc LIMIT $_GET[faqe],5") or die(mysql_error());

What am I doing wrong here? It could be a syntax error.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:57 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.