פורסם 2008 בספטמבר 2617 שנים <?phpinclude_once "/path/to/pagination.php";//...$result = $db->query("select count(book_id) as total_rows from books");$row = $result->fetchRow();$total_rows = $row->total_rows;$entries_per_page = 10;$current_page = (empty($_GET['page'])) ? 1 : $_GET['page'];$start_at = ($current_page * $entries_per_page) - $entries_per_page;$link_to = "thispage.php?param1=a_parameter¶m2=another_paramater";$result = $db->query("select * from books limit $start_at, $entries_per_page");//...?> pagination.php: (אם צריך...) <?php/* * Clean Pagination - Create clean HTML links to your pages * * PHP versions 4 and 5 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <[url]http://www.gnu.org/licenses/>[/url]. * * @author Nashruddin Amin <me@nashruddin.com> * @copyright Nashruddin Amin 2008 * @license GNU General Public License 3.0 * @version 1.0 */function clean_pagination($total_rows, $entries_per_page, $current_page, $link_to){ $total_page = ceil($total_rows / $entries_per_page); $str_page = (strpos($link_to, "?") === false) ? "?page" : "&page"; if ($current_page == 1) { $paginate_links = "<div>« Prev</div>"; } else { $paginate_links = "<div><a href=\"$link_to$str_page=" . ($current_page - 1) . "\">« Prev</a></div>"; } for ($i = 1; $i <= $total_page; $i++) { if ($i == $current_page) { $paginate_links .= "<div class=\"current-page\">$i</div>"; } else { $paginate_links .= "<div><a href=\"$link_to$str_page=$i\">$i</a></div>"; } } if ($current_page == $total_page) { $paginate_links .= "<div>Next »</div>"; } else { $paginate_links .= "<div><a href=\"$link_to$str_page=" . ($current_page + 1) . "\">Next »</a></div>"; } print $paginate_links;} אני אשמח אם מישהו יוכל קצת להסביר לי מה הולך כאן ואיך אני מתאים את זה לאתר שלי. בעקרון אני לא ממש מבין מה הולך בשורה של ה$result הראשון (וגם השני ) זה קוד שמחלק את מה שהSQL מחזיר לכמה דפים. תודה...
פורסם 2008 בספטמבר 2617 שנים תחפש מדריכים על שילוב של sql ו Php, הresult מכיל את התשובה של השאילתת SQL שעשית (הראשונה מחזירה כמה ספרים יש בטבלה והשניה מחזירה כמות מסויימת של רשומת ספרים החל ממיקום מסויים בטבלה).
פורסם 2008 בספטמבר 2617 שנים מחבר אני יודע לעבוד עם PHP וMYSQL, פשוט בדרך כתיבה הזאת לא נתקלתי.אבל מצאתי אתר שמסביר על זה קצת.ניסיתי לשלב את זה באתר שלי, אבל אני מקבל שגיאה:Fatal error: Call to a member function query() on a non-object in /home/content/i/l/a/ilanfir/html/index.php on line 46במקרה שורה 46 היא:$result = $db->query("select count(book_id) as total_rows from books");אם אני שם אותה בCOMMENT, יש לי שגיאה בשורה הבאה.
פורסם 2008 בספטמבר 2617 שנים כי לא התקנת / שילבת את הספריה הזו:http://pear.php.net/package/DB(או ספריה אחרת שמספקת את הפונקצינליות שנדרשת).
פורסם 2008 בספטמבר 2617 שנים מחבר ואיך אני מתקין/משלב את זה?נראה שאני גם צריך להתקין את הPEAR הזה...אני אשמח להסבר...
פורסם 2008 בספטמבר 2617 שנים מחבר לא ממש הבנתי על איזה PATH אתה מדבר..חוץ מזה שגם השרת לא על המחשב שלי... זה שרת באינטרנט.
פורסם 2008 בספטמבר 2617 שנים מחבר אחרי חפירה ארוכה באתר של PEAR, הצלחתי להתקין את PEAR ואת הספרייה הזאת. אבל אני עדיין מקבל את אותה השגיאה
פורסם 2008 בספטמבר 2617 שנים מחבר הגדרתי אותו בדף אחר שאני עושה לו INCLUDE...אבל יש לי קצת בעיות עם הPEAR הזה. אני קצת מסתבך איתו ועם הקובץ htaccess שצריך לעשות שם משהו...
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.