Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 3rd, 2004, 03:28 PM
Authorized User
 
Join Date: Dec 2003
Location: Sosnowiec, , Poland.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default CHPT 17.Wrong succession list 5 last added sites.

In my file is error.
The list 5-th last added sites www is show in wrong order.
If i add more than 5 url, than i can't see next url's(unless, in $num_new_sites=5; i enlarge number for something else).
I paste here my function, if everything is all right, then i please someone, to send me two files(php.directory.inc & dir_manager.php) on my mail mailto:martinpu@wp.pl in subject please write"WROX",cause i may mistake it with spam.

function list_sites($mode='top', $category_id='') {
   global $directory_tablename, $root_category_id, $PHP_SELF, $num_top_sites, $num_new_sites;
   if(!$link_id) $link_id = db_connect($default_dbname);
   if($mode=='top') {
      $order_by_str = 'ORDER BY hit DESC';
      $limit_str = "LIMIT $num_top_sites";
   }
   else {
      $order_by_str = 'ORDER BY registerdate DESC';
      $limit_str = "LIMIT $num_new_sites";
   }
   if($category_id == $root_category_id) $category_str = '1';
   else $category_str = "category_id LIKE '$category_id%'";
   $query = "SELECT url_id, title, url FROM $directory_tablename WHERE $category_str AND approved = 1 $order_by_str $limit_str";
   $result = mysql_query($query);
   if(!$result) echo sql_error();
   if(mysql_num_rows($result) > 0) {
      if($mode=='top') echo "<STRONG>$num_top_sites NAJLEPSZYCH!</STRONG><BR>";
      else if($mode=='new') echo "<STRONG>$num_new_sites NOWYCH!</STRONG><BR>";
   }
   $i = 1;
   while($query_data = mysql_fetch_array($result)) {
      $url_id = $query_data["url_id"];
      $url = "http://" . $query_data["url"];
      $title = $query_data["title"];
      echo "<STRONG> - <A HREF=\"$PHP_SELF?action=go_url&url=$url&url_id=$ur l_id\">$i. $title</A></STRONG><BR>\n";
      $i++;
   }
}

Reply With Quote
  #2 (permalink)  
Old April 5th, 2004, 06:11 PM
Authorized User
 
Join Date: Dec 2003
Location: Sosnowiec, , Poland.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think i have answer for my own question.
I don't know is this good idea, but it works.
In Function List_sites i change:"order by registerdate DESC" on "order by url_id DESC".
Every next url_id added is increment, so it works ok.:)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chpt 12 Bulk Copy smiller BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 February 13th, 2007 11:25 PM
code to make a list, anyone see what is wrong? am6019a VB How-To 3 July 13th, 2006 10:30 AM
Chpt 6 pg 204-205 harrison4411 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 June 10th, 2006 09:52 AM
Chpt 6 Why Not Try...template & navigation turtle10 Dreamweaver (all versions) 2 September 23rd, 2004 04:14 PM
Chpt 3 Please Help Me! nmj001 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 July 24th, 2003 10:52 PM



All times are GMT -4. The time now is 07:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.