NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page php help.

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 02-19-2006, 04:20 AM THREAD STARTER               #1 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



php help.


does anybody know how to make a script to show 10 results per page
J_Ronaldo_19 is offline  
Old 02-19-2006, 05:17 AM   #2 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
Tree will become famous soon enoughTree will become famous soon enough
 



10 results of what? A database query?
Tree is offline  
Old 02-19-2006, 06:07 AM   #3 (permalink)
Senior Member
 
superprogrammer's Avatar
Join Date: Aug 2004
Location: Washington
Posts: 4,324
superprogrammer has much to be proud ofsuperprogrammer has much to be proud ofsuperprogrammer has much to be proud ofsuperprogrammer has much to be proud ofsuperprogrammer has much to be proud ofsuperprogrammer has much to be proud ofsuperprogrammer has much to be proud ofsuperprogrammer has much to be proud of
 



Its simple Ronaldo
use $_GET['page']
and then divide pages based on the number of rows fetched divided by 10
use it as hyperlink and there you go.!!
__________________
Download youtube videos at www.HugYouTube.com -NO LINKS TO PARKED PAGES-
Anonymous access at www.Banned.net
superprogrammer is offline  
Old 02-19-2006, 10:57 AM THREAD STARTER               #4 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



that seems harder than it looks.

I mean like google do for there search engine
J_Ronaldo_19 is offline  
Old 02-19-2006, 11:09 AM   #5 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,963
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
Basically you need the LIMIT clause if you are pulling results from a mySQL DB.
For example to display page 1 you need a query like
PHP Code:
select record from table order by whatever LIMIT 0,10 
????: NamePros.com http://www.namepros.com/programming/169083-php-help.html
this will return the first 10 records with the sort order you specify

then for page 2
PHP Code:
select record from table order by whatever LIMIT 10,10 
you have the next 10 records and so on
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is online now  
Old 02-19-2006, 11:18 AM THREAD STARTER               #6 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



I need it automated because this is a search engine where people submit there sites so...
J_Ronaldo_19 is offline  
Old 02-19-2006, 11:24 AM   #7 (permalink)
Account Closed
Join Date: Aug 2005
Posts: 373
clowesy is a jewel in the roughclowesy is a jewel in the roughclowesy is a jewel in the rough
 



select record from table where ID>'$_GET[startid] LIMIT 10;

then make the links page.php?startid=0 etc
clowesy is offline  
Old 02-19-2006, 12:41 PM THREAD STARTER               #8 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



Your all confusing me what should I do?
J_Ronaldo_19 is offline  
Old 02-19-2006, 01:05 PM   #9 (permalink)
NamePros Regular
 
Palyriot's Avatar
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 596
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
 



It's called pagination...here is a link to a tutorial you can use... http://www.phpfreaks.com/tutorials/43/0.php

I used the same tutorial my first time..Good luck.
Palyriot is offline  
Old 02-19-2006, 01:09 PM THREAD STARTER               #10 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



Im not that new to PHP just... "Pagination" I'll look at this tommorrow

EDIT: What don't I need in this code?

PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=169083

    
@mysql_connect($localhost$user$password) or die("ERROR--CAN'T CONNECT TO SERVER");
    @
mysql_select_db($database) or die("ERROR--CAN'T CONNECT TO DB");

    
$limit          25;               
    
$query_count    "SELECT count(*) FROM table";    
    
$result_count   mysql_query($query_count);    
    
$totalrows      mysql_num_rows($result_count);

    if(empty(
$page)){
        
$page 1;
    }
        

    
$limitvalue $page $limit - ($limit);
    
$query  "SELECT * FROM table LIMIT $limitvalue$limit";        
    
$result mysql_query($query) or die("Error: " mysql_error());
????: NamePros.com http://www.namepros.com/showthread.php?t=169083

    if(
mysql_num_rows($result) == 0){
        echo(
"Nothing to Display!");
    }

    
$bgcolor "#E0E0E0"// light gray

    
echo("<table>");
    
    while(
$row mysql_fetch_array($result)){
        if (
$bgcolor == "#E0E0E0"){
            
$bgcolor "#FFFFFF";
        }else{
            
$bgcolor "#E0E0E0";
        }

    echo(
"<tr bgcolor=".$bgcolor.">n<td>");
    echo(
$row["users"]);
    echo(
"</td>n<td>");
    echo(
$row["usersID"]);
    echo(
"</td>n</tr>");
    }

    echo(
"</table>");

    if(
$page != 1){
        
$pageprev $page--;
        
        echo(
"<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> ");
    }else{
        echo(
"PREV".$limit." ");
    }

    
$numofpages $totalrows $limit;
    
    for(
$i 1$i <= $numofpages$i++){
        if(
$i == $page){
            echo(
$i." ");
        }else{
            echo(
"<a href=\"$PHP_SELF?page=$i\">$i</a> ");
        }
    }


    if((
$totalrows $limit) != 0){
        if(
$i == $page){
            echo(
$i." ");
        }else{
            echo(
"<a href=\"$PHP_SELF?page=$i\">$i</a> ");
        }
    }

    if((
$totalrows - ($limit $page)) > 0){
        
$pagenext $page++;
         
        echo(
"<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>");
    }else{
        echo(
"NEXT".$limit);
    }
    
    
mysql_free_result($result);

?>
Last edited by J_Ronaldo_19; 02-19-2006 at 01:41 PM.
J_Ronaldo_19 is offline  
Old 02-19-2006, 04:41 PM   #11 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
Tree will become famous soon enoughTree will become famous soon enough
 



I'd say that you need most everything in that code.
Tree is offline  
Old 02-19-2006, 05:46 PM   #12 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Yep..... however, there are "easier" ways to do this with much less code ... such as

PHP Code:
<?php

$page 
intval($_GET['page']);
????: NamePros.com http://www.namepros.com/showthread.php?t=169083

if(!
$page || $page == "")
{
  
$page 1;
}

$prev $page 1;
$next $page 1;
$ppage 10;
$limit = ($page $ppage) - $ppage;

$query mysql_query("SELECT field FROM table") or die(mysql_error());
$num mysql_num_rows($query);
$num_pages ceil($num $ppage);

$link '';

if(
$page 1)
{
  
$link .= ' <a href="?page=1">First</a> <a href="?page='.$prev.'">Prev</a> ';
}

for(
$i 1$i <= $num_pages$i++)
{
  if(
$page == $i)
????: NamePros.com http://www.namepros.com/showthread.php?t=169083
  {
    
$link .= ' <b>['.$i.']</b> ';
  }
  else
  {
    
$link .= ' <a href="?page='.$i.'">'.$i.'</a> ';
  }
}

if(
$page $num_pages)
{
  
$link .= ' <a href="?page='.$next.'">Next</a> <a href="?page='.$num_pages.'">Last</a>';
}

$sql mysql_query("SELECT * FROM table LIMIT ".$limit.", ".$ppage) or die(mysql_error());

while(
$row mysql_fetch_array($sql))
{
  
//Do your thang here
}

//You end up having your link in the $link variable 
//so you could echo it anywhere on down the page....

echo $link;

?>
Eric is offline  
Old 02-19-2006, 11:55 PM THREAD STARTER               #13 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



I have all the query results set out all I need is to group it, is that the code.

EDIT:

PHP Code:
  <?php

$page 
intval($_GET['page']);

if(!
$page || $page == "")
{
  
$page 1;
}

$prev $page 1;
$next $page 1;
$ppage 10;
$limit = ($page $ppage) - $ppage;

$query mysql_query("SELECT field FROM pm_search") or die(mysql_error());
$num mysql_num_rows($query);
$num_pages ceil($num $ppage);

$link '';

if(
$page 1)
{
  
$link .= ' <a href="?page=1">First</a> <a href="?page='.$prev.'">Prev</a> ';
}

for(
$i 1$i <= $num_pages$i++)
{
  if(
$page == $i)
  {
    
$link .= ' <b>['.$i.']</b> ';
  }
  else
  {
    
$link .= ' <a href="?page='.$i.'">'.$i.'</a> ';
  }
}

if(
$page $num_pages)
{
  
$link .= ' <a href="?page='.$next.'">Next</a> <a href="?page='.$num_pages.'">Last</a>';
}

$sql mysql_query("SELECT * FROM pm_search LIMIT ".$limit.", ".$ppage) or die(mysql_error());

while(
$row mysql_fetch_array($sql))
{





?>


<table width="100%" border="0" cellspacing="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" class="text">
            <? while ($row mysql_fetch_array($check))
            { 
?>
                <tr>
                        <td width="100%">
                            <font class="link">
                            <a href="<? echo $row[url]; ?>"><? echo $row['title']; ?></a><br>
                            </font>
                            <? echo $row['description']; ?><br>
????: NamePros.com http://www.namepros.com/showthread.php?t=169083
????: NamePros.com http://www.namepros.com/showthread.php?t=169083
                            <font class="reallink">
                            <? echo $row['url']; ?>
                            </font>
                        </td>
                    </tr>
        <?    }   ?>
                </table>
                <br><br>
                </body>
                </html>
<?    }
}

if (
$_GET[act] == "search")
    
search();
else
    
newsearch();





}

//You end up having your link in the $link variable
//so you could echo it anywhere on down the page....

echo $link;

?>

Thats what I have and all it gives me is a blank screen :S
Last edited by J_Ronaldo_19; 02-20-2006 at 09:14 AM.
J_Ronaldo_19 is offline  
Old 02-22-2006, 12:43 AM   #14 (permalink)
NamePros Regular
 
Palyriot's Avatar
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 596
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
 



You should probably read the tutorial instead of just going to the very end and getting the final code. That way, you'll know how to make it work for your site.
Palyriot is offline  
Old 02-22-2006, 06:54 AM THREAD STARTER               #15 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



I read it and configured but all I got was a white screen :S
J_Ronaldo_19 is offline  
Old 02-22-2006, 12:28 PM   #16 (permalink)
NamePros Regular
 
Palyriot's Avatar
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 596
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
 



If you aren't even getting the page numbers, then your mysql query isn't working correctly. Look through your query and test it out a few other ways.
Palyriot is offline  
Old 02-23-2006, 09:21 AM THREAD STARTER               #17 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



Ive tried ever Pagination script I can find nothing works :S
J_Ronaldo_19 is offline  
Old 02-23-2006, 05:09 PM   #18 (permalink)
NamePros Regular
 
Noobie's Avatar
Join Date: Feb 2006
Location: Montreal, Quebec, Canada
Posts: 324
Noobie is on a distinguished road
 



If you can use PEAR use the Pager class with the DB pager wrapper

http://pear.php.net/package/Pager
__________________
Goldkey.com is a scam
What's your BMI? | Timestamp Generator
Noobie is offline  
Old 02-24-2006, 08:01 AM THREAD STARTER               #19 (permalink)
Account Suspended
Join Date: May 2005
Location: Huddersfield, England
Posts: 179
J_Ronaldo_19 is on a distinguished road
 



I don't understand PEAR what is it and what am I ment to download from it to help me
J_Ronaldo_19 is offline  
Old 02-24-2006, 12:51 PM   #20 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
Tree will become famous soon enoughTree will become famous soon enough
 



Pear is a PHP class that does wonderous things.
Tree is offline  
Old 02-24-2006, 06:11 PM   #21 (permalink)
NamePros Regular
 
Noobie's Avatar
Join Date: Feb 2006
Location: Montreal, Quebec, Canada
Posts: 324
Noobie is on a distinguished road
 



Originally Posted by Tree
Pear is a PHP class that does wonderous things.
Amen

J_Ronaldo_19: go to pear.php.net and read up a little. If you need help with specific things I can try.
__________________
Goldkey.com is a scam
What's your BMI? | Timestamp Generator
Noobie is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 01:39 AM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 09:09 AM

 
All times are GMT -7. The time now is 02:09 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger