Advertisement

08.28.2006 at 10:37AM PDT, ID: 21969892
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

PHP MySQL - combining a paging script with a HTML table-creating while loop

Asked by DarkLookingGlass in PHP Scripting Language

Tags: , , ,

Hello Experts,

I have a script which queries a mysql db and returns its results in a HTML table.
The problem is there are hundreds of returns, so a paging script would be in order.
Based off of the tutorials I found elsewhere in EE, I built the Paging Script below.

My problem is I don't know how to deal with the paging script's need to use the Header Function.

This is the last part of a new section of a company website I am setting up.
Hence the high point value...

Thanx,
DLG


-----   Table Maker Script    -----

// evaluate whether or not Collection has been passed

$value = (isset($_GET) && array_key_exists('collection', $_GET)) ? $_GET['collection'] : false;
// If collection is not set, display a paginated table of collections
if ($value === false) {
       $resultn = mysql_query("SELECT * FROM tblItems GROUP BY item_collection") or die("Sql Error : " . mysql_error());
         echo '<table class="content">';
         echo '<tr>';
         $c = 0;
         while($row1 = mysql_fetch_array($resultn)) {
         $c++;
         echo '<td>';
         echo '<a href="collection_table.php?collection=' . $row1['item_collection'] . '">';s
         echo '<img class="content" src="'. $row1['image_path'] . $row1['image_file_low'] . '"><br/>' ;
         echo $row1['item_collection'];
         echo '</a>';
         echo '</td>';
            if ($c == 5) {
            $c = 0;
            echo '</tr>';
             echo '<tr>'; //end the old row and begin a new one
     }
}
         echo '</tr>';
         echo '</table>';
         echo '/<div>";



} else {

-----   Table Maker Script    -----

-----   Paging Script    -----

<?PHP
if ( $_REQUEST['number'] == NULL ){
$limit = 10;
} else {
$limit = $_REQUEST['number'];
}

if ($_REQUEST['page']==NULL){
$start = 0;
} else {
$start = $_REQUEST['page'];
}

if($_GET['page'] < 0){
header("Location: category_searchy.php?page=0&number=".$limit);
}

$query = mysql_query("SELECT * FROM tblItems LIMIT $start, $limit") or die(mysql_error());

while ($row = mysql_fetch_array ($query) ) {
echo '<p>'.$row['item_number'].'</p>';

}                            

$previous = $start - $limit;
$next = $start + $limit;
echo '<a href="category_searchy.php?page='.$previous.'">Previous</a> - ';
echo '<a href="category_searchy.php?page='.$next.'">Next</a>';

?>

-----   Paging Script    -----Start Free Trial
[+][-]08.29.2006 at 01:58AM PDT, ID: 17410117

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: paging, php, script, mysql
Sign Up Now!
Solution Provided By: OrsoAle
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.30.2006 at 11:45PM PDT, ID: 17426645

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.31.2006 at 10:19AM PST, ID: 17844142

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.04.2006 at 05:55AM PST, ID: 17873240

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32