Current location: Hot Scripts Forums » Programming Languages » PHP » multiple page view


multiple page view

Reply
  #1 (permalink)  
Old 10-24-07, 03:03 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
multiple page view

Hi there..

I got this question:

The result of my DB-search are displayed with this script:

PHP Code:

extract($_POST);


// Make a MySQL Connection

$word $town;

if(
$soort == "geen") { $soort "[[:alnum:]]"; }
if(
$kamers == "0") { $kamers "[[:digit:]]"; }
if(
$woonopp == "0") { $woonopp "[[:digit:]]"; }
if(
$perceelopp == "0") { $perceelopp "[[:digit:]]"; }

$word1 explode(" ",$word); // Extract the words from $word and store them in array $word1. All words in $word must be seperated by spaces.
$operator "|"// Set regex operator to "|".
if($word)
{
 
$word "'"// Prepare $word for new string
 
for($i=0;$i<count($word1);$i++)
 {
  if(
$word1[$i] && $word1[$i] != ""// Check to see if $word started or ended with a space or contains multiple spaces.
  
{
   
$word .= $word1[$i].$operator// Add the words to $word
   
}
  }
 
$word substr($word,0,strlen($word)-1); // Remove the last "|"
 
$word .= "'"// Add closing ' to $word
 
if($word == "'"){$word "' '";}
 
$result mysql_query("SELECT * FROM exemple WHERE town RLIKE $word AND kind RLIKE '$soort' AND rooms RLIKE '$kamers' AND size >= '$woonopp' AND size2 >= '$perceelopp' AND price BETWEEN '$pricefrom' AND '$pricetill'") or die(mysql_error());

else{
$result mysql_query("SELECT * FROM exemple WHERE kind RLIKE '$soort' AND rooms RLIKE '$kamers' AND size >= '$woonopp' AND size2>= '$perceelopp' AND price BETWEEN '$pricefrom' AND '$pricetill'"
 or die(
mysql_error());
}

 
$num_rows mysql_num_rows($result);
 If(
$num_rows || !$num_rows)
 {
  echo 
"No results.";
  }
 else
 {
  while(
$row mysql_fetch_array($result))
  {
   
// Print out the contents of each row
   
echo $row["adress"]." - ".$row["town"]."<br />";
   }
  } 
It works great with me... but there is something I couldn't manage:

I want 4 items found to be displayed... under these items I want a row with a number of pages (1-2-3-4-5-6...) what shows the other results.

who can help me out..?

_j
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-24-07, 03:20 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
There are literally thousands of tutorials online. Google for "PHP Pagination tutorial".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-24-07, 06:08 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
hmmm.. you're right.. there are a lot...

but cause I'm new with mysql it's gonna take a while..
I'll give it a try... when I come up with some problems
I'll know how to find you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-24-07, 06:59 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
can you help me getting started?... I tried a tutorial and came up with this but doesn't makes sence to me...:

PHP Code:

extract($_POST);
extract($_GET);

global 
$limit;
global 
$page;

// Make a MySQL Connection

$word $woorden ;
$word1 explode(" ",$word) ;
$operator "|" ;
if(
$word)
{
 
 
$word "'";
 for(
$i=0;$i<count($word1);$i++)
 {
  if(
$word1[$i] && $word1[$i] != ""// Check to see if $word started or ended with a space or contains multiple spaces.
  
{
   
$word .= $word1[$i].$operator// Add the words to $word
   
}
  }
 
$word substr($word,0,strlen($word)-1); // Remove the last "|"
 
$word .= "'"// Add closing ' to $word
 
if($word == "'"){ $word "' '";
 }
 
 
$result mysql_query("SELECT * FROM aanbod WHERE adres RLIKE $word OR plaats RLIKE $word OR verhaal RLIKE $word")  or die(mysql_error());
   
$total_items mysql_num_rows($result);

 
$num_rows mysql_num_rows($result);
 
 if(
$num_rows || !$num_rows)
 {
  echo 
"Er zijn geen resultaten gevonden voor u zoekopdracht. Pas uw zoekcriteria aan en probeer het nogmaals.";
  }
 else
 { 
 
 
$limit        $_GET['limit'];
 
$page        $_GET['page'];

 if((!
$limit)  || (is_numeric($limit) == false) || ($limit 10) || ($limit 50)) {
     
$limit 3//default
 

if((!
$page) || (is_numeric($page) == false) || ($page 0) || ($page $total_items)) {
      
$page 1//default
 
}
 
 
$total_pages     ceil($total_items $limit);
 
$set_limit     $page $limit - ($limit);

 
$result mysql_query("SELECT * FROM aanbod WHERE adres RLIKE $word OR plaats RLIKE $word OR verhaal RLIKE $word")  or die(mysql_error());

 
//show data matching query:
while($results mysql_fetch_array($result)) { 
   echo 
$results["adres"]." - ".$results["plaats"]."<br />";
}

 
$prev_page $page 1;

if(
$prev_page >= 1) { 
  echo(
"<b><<</b> <a href=http://www.kerkvlietmakelaars.nl/search-results2.php?limit=$limit&page=$prev_page><b>Prev.</b></a>"); 


for(
$a 1$a <= $total_pages$a++)
{
   if(
$a == $page) {
      echo(
"<b> $a</b> | "); //no link
     
} else {
  echo(
"  <a href=http://www.kerkvlietmakelaars.nl/search-results2.php?limit=$limit&page=$a$a </a> | ");
     } 


$next_page $page 1;
if(
$next_page <= $total_pages) {
   echo(
"<a href=http://www.kerkvlietmakelaars.nl/search-results2.php?limit=$limit&page=$next_page><b>Next</b></a> > >"); 
}
}
}
else{echo 
"You must enter some search data.";
}
?> 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
View page through page TheCase PHP 10 10-03-07 11:02 AM
[turnkey] Lyrics site - $149 (LEGAL) rightinpoint General Advertisements 0 10-22-06 05:33 AM
Multiple Page PHP Registration form losse PHP 6 06-24-06 11:33 PM
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM


All times are GMT -5. The time now is 08:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.