Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Displaying X Number Of Results Per Page


What I need to do is this. I query a MySQL database and, for example, 400 results are returned. I can get it to display the number of results, but I would like to set a value to display, say 20, results per page and generate numbered links with and offset to browse through and next/previous buttons -not unlike this page. Can anyone point me in the direction of a good article or if you have it, post some code here?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying X Number Of MySQL Results Per Page
I'm writing a search on a MySQL DB, and everything so far has just gone swimmingly. I've got a "results per page" drop down box in my form, with a few different values.

At the moment, I'm just using:

while($myrow = mysql_fetch_array($result)

to output results to screen.

I'm not too sure how to go about it, but I did have two thoughts:

1) Suck the results into a multi-dimensional array, and pass the array to a display results script (not sure if you can pass arrays to other scripts???

2) Display x number of results, then have the "Next" (or 2, 3... ) links call the search again, but displaying results x+1 - x+x.

1 sounds like too much trouble, and 2 sounds inefficient. Not too sure how else to go about it. Any info / thoughts you guys have would be much appreciated.

On a side note, how do you look at a specific row in the result?

Results Only X Number Per Page...
am doing a real state site and when searching it shows all the results from the database in one single webpage, can you help me with one easy way to show only 10 results per page?

I've seen some complicated sites with previous and next arrows, i only need to show 10 results then a link to show next 10 and that's it.

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

Displaying Limited Results
I have a problem that is related to limiting the results displayed in a page. I have a numbered pagination script working that has a limit etc. At the moment it is milited to displaying 8 results before producing the next link.

What I have is a table with 2 columns and 4 rows....a grid of 8. I want the results to start in the top left and then when 2 table cells have been created it will start a new row and do this for all of the results ie:

1 2
3 4
5 6
7 8

Basically, i need code that will make a new row start when 2 results have been displayed in that row.

Displaying A Message If A Number Goes Negative.
I'm trying to display a comment if my query comes up nagative, my result is displayed as a time (00:00:00 Format), I want it so that when my time goes negative (-01:00:00) it will display a comment, but when it is positive it will display the time. I already have the time displayed by using:

print $record['time_diff'];

But I'm not very clued up when it comes to if and else commands.

This is a section of my code that I can't get to work, Im sure you will see the problem straight away but I can't and have tried a few things.

$result = mysql_query($query = "SELECT timediff(time_allowed, time_used) as time_diff FROM scheduled_time WHERE scheduled_time.id = 1");
$record = mysql_fetch_assoc($result);
if ($record['time_diff']> 0){
print $record['time_diff'];
} else {
print "Time is negative";
}

Any help would be greatful.

Displaying Specific Number Of Queries.
If I wanted to only display the first 10 queries from MySQL on my webpage, how would I do that? Also, say if I wanted to only display queries 11 - 20, how would I do that?

Displaying The Number Of Featured Ads In Mysql
I was looking for away to have it display how many featured items are in a table then display that number in the admin next to the featured item check box that way the person know how many items are currently featured.

Displaying A Table Using ID Number As Hyperlink
i am able to insert and display data to the end user, but i am trying to let the end user edit a row. I am unsure how this is usually done, but i am have the following code to display by data

 echo "<table border='1'><thead><tr>";
            for($i = 0;$i < mysql_num_fields($sql_result);$i++)
            {
             echo "<th>".mysql_field_name($sql_result,$i).
                  "</th>";
            }
     echo "</tr></thead>
           <tbody>";
     for ($i=0;$i < mysql_num_rows($sql_result);$i++)
     {
        echo "<tr>";
        $row = mysql_fetch_row($sql_result);
        foreach($row as $value)
        {
           echo "<td>".$value."</td>";
        }
        echo "</tr>";
     }
     echo "</tbody></table>";

The user have a jump menu (combo box) to pick the table they need to show information on, so the columns displayed are going to vary, but i have a column called ID which is the same in each tables which is the index (auto increment) field.

I was thinking about using this number comnbined with a hyperlink, so the user can click it to take them to a page to edit that row.... But i have no idea how to do this, or if there is an easier way which i just do not know; or how do most people achieve what i require...

Help With Function For Displaying Calculation Results
I am developing a betting calculator and at the moment I am working on some functions that can be used to display the HTML for the form to enter your bet and odds and the results.

I am still relatively new to PHP and I am learning all the time so sorry if this is a simple problem!

I have 3 files: calc1.php, index.php and funtions.php

Here is index.php PHP Code:

Displaying Results On Multiple Pages
I have a search query via PHP and MySQL that has list of results, but I only want to show 10 or 15 on a page. Much like Yahoo! or even here on the Devshed forums. I have been working on a system that cycles through all the results with a while loop and a counter. It only displays results >= 11 or <=20 as an example. I am passing that data (the results start point through the url) I am just worried that if the results are in the thousands this system would get very slow.Is there an easier/better way that I am not seeing?

Nesting Queries And Displaying Results.
i am in the process of trying to make a simple system to keep track of switch ports and what points they are conencted to. the problem i am having is with displaying the data from my ports table. Code:

mysql> select * from Switch_Ports;
+------+----------+---------+------------+--------+
| SwID | Port_NO | VLAN | Patch_Port | PortID |
+------+----------+---------+------------+--------+
| 1 | fa1/0/1 | staff | AA10 | 1 |
| 1 | fa1/0/2 | staff | AA12 | 2 |
| 2 | fa1/0/10 | staff | AA100 | 3 |
| 2 | fa4/0/12 | staff | BB12 | 4 |
| 3 | fa2/0/11 | student | A16 | 5 |
| 3 | fa1/0/23 | student | B14 | 7 |
+------+----------+---------+------------+--------+

SwID relates back to my Switch table, which contains dns names and stuff like that. for example i want to be able to display the ports from SwID 1 PHP Code:

Displaying Array Results In Table
I'd like to display the results of an array in a table format with the Alias, Alias Destination & Username as column headings & the results underneath. PHP Code:

Displaying Database And Getting Unwanted Results...
I want to display everyone in the database, but only if the 'level' field is larger than 0.  Well, this works fine for most of the database... but if the last entry in the database is 0, then it prints it anyways.

Is there anyway around this?  I tried adding an if statement before the last bit where I echo out the table rows, but it was killing the entire table, or still showing the same results. Code:

Displaying Results With Decimals, And Stylizing Them.
I just have what I think is an easy question for some of you. I have a page that pulls all the entries from a specific table in the database. The results are displayed in a table. In this table there is  column for "job_number" this job number is a decimal entry, i need to display the job numbers, grouped by the the numbers ahead of the decimal place and then ordered by the numbers after the decimal. I would also like to indent the decimals ONLY numbers below the under that does not have a decimal. Code:

Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format.  For example the following text in this format including the lines in stored in the database:

Quote“Hello,

Welcome to the news for 11/06/07.

Thanks”
When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this.  Quote“Hello, Welcome to the news for 11/06/07. Thanks”  How do I get it to display in the format it in displayed in the database?

Displaying Search Results In Pages
I am implementing search functionality in a website. ( internal search).
In that I am taking a keyword as input and searching all the pages and storing
results in an array. I want to display 10 results per page. I wrote below logic for that. Code:

Displaying MySQL Results As URLs
I'm attempting to turn the results of a query into urls, yet I keep getting this error, "Parse error: syntax error, unexpected '<' in staff.php on line 190." I've coded and recoded this, yet for some reason I cannot get this error to go away. I know it's probably simple, but what am I missing? Code:

Displaying A Varying Number Of Images.. In Tables?!
I'm building a news system. I have a page to display all posts made to
category=$id, simple enough, now I wanna make an index page that looks
up all the categories from the news_topics table, displays their name,
a link to their page, and the image assigned to that category.

Here's the catch: I wanna put this in a table as the images are only a
few hundred pixels wide, so a flat list of each image would be boring
and inefficient. The thing is, we may add/remove news categories over
time, so how can I deal with this?

Would it really be easier to manually make this in HTML and change it
as/when we make modifications to the topics table?

Count Displaying Multiple 0 Instead Of Actural Number
I've been having this problem with the count, i've had it working for the other page, but that one uses a ID tag of 1 - 50. This one uses a jcode thats constantly changing. PHP Code:

Display The Number Of Results
How can I set the classical search engine message? Found ### results. How can I count the returned results and display them in the results page? so now has the Found 5 results or any number that the result contains.

Displaying SELECT Results In A Formatted Table
I was wondering how to show a table with a max limit of 20 results per page. I have various data being pulled and its putting it in a table, but its displayed all in one row. I want to format it so its a 4 column/5 row table. With that I then want the page to generate a numbered list at the bottom that calculates how many pages it takes to show 20 items on each. Code:

Displaying SQL Query Results In 3 Column Table
I would like to be able to display the results of an sql query in an html table, but the results need to be displayed in three columns, for example:

Column 1   Column 2   Column 3
Result 1     Result 2     Result 3
Result 4     Result 5     Result 6
Result 7     Result 8     Result 9

I've tried to find the answers on the internet but i can't find anything that suits my needs!

Displaying Select Information From XML Search Results
I am new to both php and xml. I have a school assignment to update an existing php-based website where I have to display search results from an online library. I can use a url search which returns an XML file that includes tags such as position, title, url, description, date, etc.

I only want to display the title, url (preferably the title should be a link to the url), and description for all of the results on my website's search results (different template as well).

What classes/functions are available to help me do this? I would appreciate any guidance as well as links to online tutorials etc. that would point me in the right direction. I have read about the general aspects of php, and I have experience with Java and C; but I don't know about xml at all.

By the way, the website is running on the school server and has php version 4. I don't think I'll be able to install php 5 but I can probably upload some helper files or something.

Display Number Of DB Results Beside A Link?
For an example, if you look at www.menupages.ie they give you a preview of how many results are found for each link.

ie:

 Ballsbridge Restaurants   (52)
 Blackrock Restaurants  (17)
 Clondalkin Restaurants  (18)
 Clontarf Restaurants  (17)

How is this achieved. I take it that it must be a select count on the DB for each row but that seems pointless, is there an easy way to achieve this?

I Get The Number Of Raws From A Query, But Can't See Results
I get the number of raws from a query, but can't see results?

Page Control - Next/previous Or Select Page Number
I'm looking for php script examples that will help me control page layout. Using a table with 12,000 records, would like to be able to display only 5 records per page with page controls at the bottom of the page. The bottom edge would have next/previous or an optional insert desired page number.

Displaying Parts Of A Page While The Page Is Not Complete Yet
A script I'm writing outputs a HTML table with many rows. Each row is the result of a query which takes about one minute to perform. When I run the script in a browser, the page takes several minutes to load and then displays the entire table. Is it possible (using PHP) to display the table as it gets constructed, one row at a time?

Retrieving,Sorting & Displaying Multiple Results From Mutliple Tables
I need to know how to run a php / mysql query to do the following.

I have 1 database (lets call it "database" for now) within this database there are multiple tables ("News","Feature","Header_feature")

For NEWS I need only the 6 latest results pulled from that table and displayed in a table.  The "News" table has the following columns "ID","Title","Date","Body","Image"

For Feature I need only 1 result retrieved from the database and displayed under the variable $ticker as it will display as a scrolling marquee within a table.  The "Feature" table has the following columns "ID","Ticker".

For Header_feature I need only 1 result retrieved from the database and displayed in the following manner <a href="$link"><img src"$header_feature">[/url]  The "Header_feature table has the following columns "ID","image","link"

How would I code this all into 1 page?  I cant seem to get the query to do everything I want it to and display the results properly.  You can see what I have so far at www.getlivemedia.com  The $ticker is the scrolling text near the top of the page and the news is obviously the bulk of the page and $feature_image is the broken image.

Displaying A Page At A Specified Position
I have a form about half way down a web page, which posts criteria for the
WHERE part of an sql which then returns the results at the bottom of the
page.

Trouble is when the page reloads it goes to the top of the page again so the
results are not visible and the user is sometimes unaware that anything has
happened.

I could get a message to display at the top to tell user to scroll to
bottom but i would prefer the page to display at the start of the records(in
a html table).

Displaying Just A Blank Page??
I have commented out a lot of my code and have realised that the code below is what the problem is. I have placed ini_set('display_errors', 'on');
error_reporting(E_ALL);  at the very top of the page. No errors are displaying. However I can't see what the problem could be. Code:

Displaying Mysql On Web Page
i am archiving data in mysql, each has an id number from smallest (oldest) to largest (newest), by the week. on my website, i would like to display only the newest week and the week before it. (or the weeks with the largest ids). how can i do that?

Displaying Page Render Time
Some sites (some forum software etc) have a line at the bottom of the page that says Page rendered in 0.0002414 seconds or something of that ilk.

My question is - how would one code this? The only way I could think would be to take the time at the top of the page and the time at the bottom of the page, take one from the other and display that - am I on the right track?

Displaying Text While Page Is Loading
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>'
flush();
sleep(10);
echo 'BBB'
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>'
ob_flush();
flush();
sleep(10);
echo 'BBB'
?>



Displaying Last Visitor On Profile Page
I'm in the process of malking a php/mysql website where each registered member has a profile page. This is what I'm trying to achieve:

-When some member visits someone else, I want that someone to see the recent visitor's username on his/her profile page. Can someone give me some hints on how this could be done?

Go To Page Number
how I could go about this using dropdowns that would select from table limit by like 10 or 15 results per page. I kind of get prev next.

Having Different Results On Same Page
I have a database that I would like to use to display the contents in different lists on the same page. In other words, I would like a list of the latest 15 entries in the database to appear in list...then I would like the next 15 to appear on the same page but in a different list structure, etc. I have this so far, but it only displays the latest 15...I am stuck on how to get another list generated from the same query: Code:

Displaying Html Code On PHP Generated Page
I am trying to create a link page in my php application. this is a page that will display a block of html code that a visitor can copy and paste into their web site to create a link back to mine. My PHP page has a line in it like this:

define('TEXT_INFORMATION', '<html page code is here>');

I have added the html code to create the page as noted above. the page contains a same of the banner image file and the html code that goes alon with it. My problem is that I haven't been able to "quote" the html code so that ir will not be executed.

every time I try to run the application from my web server my page will display two copies of the banner iimage not on banner image and text block like it should. Any suggestions?

Displaying A URL Stored In A Table As An Image On The Page?
In a table in my database I have a column for storing the URL of an image of a product. What PHP code would I use to display the image? PHP Code:

Stripping Http:// Form A Url When Displaying To A Page...
Hi I'm trying to display URL's in my link exchange like google does.

Here is the function to display the Link, Description and URL:

Displaying Members Edit Profile Page
I have an edit profile page for my memebership system which works fine until i call a function to make sure that the user is logged in before displaying the content with their details.

When I log in and go onto the edit profile page, all the form fields are there but as soon as I click submit the page goes blank.  I don't have this problem if I don't use the function but how else am i supposed to only display the page to registered and logged in users? Code:

Format Source Code For Displaying On A Web Page
Is there a good function or plugin out there to format my source code examples?  I'm writing an article for a web page and want a very simple source code formatter.  Eg: code in black, comments in red, quoted items blue, key words green, class names bolded.

Page Number Problem
What I am doing is that My data should come out 5 datas. If I have 15 datas, it should show up 3 links to next page. However, my page link doesn't come out. I don't know why??
PHP Code:

Page Number Creation
I have a working page number script but the only problem is that when I get some many fields to display the pages go way off the screen and it gets messy. Anyone have any good ideas to edit this script to maybe only display 10 pages at a time but go up as you go up in pages? Code:

Use Arrays To Page Through Results?
I've got a search facility that interrogates an SQL database then shows the results 30 at a time. Currently, when you go to the next page of results it has to run the query all over again, because there is no way of handing the resultset to the PHP file. So I wondered if there was another way of doing it.

I'm tempted to use mysql_fetch_array and create a multi-dimensional array full of result rows, then hand that around, but so far cannot find out how to hand a PHP array as a variable to a PHP page.

IS this possible, or am I barking up the wrong tree? Or is there a better way of doing this?

How Do I Make The Results Appear On The Same Page?
Presently i am calling a new file to accept my dropdownlist values. Is it possible to make it such that the results will just appear on the same page? Code:

PING Results On PHP Web Page!
Can someone show me sample code on how can I write a script that shows ping results on a web page.

Multi-page Results....
I'm working on an engine to search a MySQL database of a bunch of forum messages. The PHP code retrieves the results from the database, then stores them into an multi-dimensional array for processing.

Once stored, the code parses each result and assigns it a relevancy score, and once all of the results are scored, it then sorts all of the results according to relevance. The end product off all this is an array that holds all of the retrieved messages relevant to the search, holding such information as title, author, date, msgID, blah blah blah. now that i've kinda explained what's going on, i'll get into the problem i've bumped into.

Being that there's roughly 16,000 messages in the database (not to mention the 800,000 lines of message text) that could possibly be the results from a query, displaying it all on one page is most definately out of the question (it still takes a few seconds to load on my cable line with only a few hops to the T3'd server. I'd hate to see what a 33.6 or 56k user would be waiting for).

The real problem all comes down to: how am I going to pass the results from one page to the next? an array of a few thousand messages is a *little* large for an http post action, and storing the results in a table in the mysql database posses a few problems as well (namely, how long to keep the table around after the user has executed the search. temporary tables are out of the question, as they die as soon as the mysql connection is closed, but a persistent mysql connection would create exactly the opposite problem: ei, temp. tables never die).

10 Results Per Page But From Different Categories
I have a script that shows a list from a different category depending on what is in the URL. I've got it to limit the results to the 1st ten results and keep the chosen category in the link(?category=differentcategory) but when next page is clicked it repeats the same ten results. Code:

SQL Query - Results From Another PHP Page ?
Can I store this PHP code in another page, then refernece it on
multiple pages using Require or Include ???

//results from sql query
for ($i=0; $i<$number; $i++) {
$ID = mysql_result($result,$i,"ID");
$CompanyName = mysql_result($result,$i,"1");
$ContactName = mysql_result($result,$i,"2");
$Phone = mysql_result($result,$i,"3");
$HomePhone = mysql_result($result,$i,"4");
$MobilePhone = mysql_result($result,$i,"5");
$AltPhone = mysql_result($result,$i,"6");
$SecondContact = mysql_result($result,$i,"7");
$SecondPhone = mysql_result($result,$i,"8");
$ThirdContact = mysql_result($result,$i,"9");
$ThirdPhone = mysql_result($result,$i,"10");
$Notes = mysql_result($result,$i,"11")


Copyright © 2005-08 www.BigResource.com, All rights reserved