Add to Google

Displaying 10 Records Per Page

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Displaying 10 Records Per Page

dvayne
how to display 10 messages per page?
CODE
<?php
    include("config/config.inc.php");
    include("config/dbcon.php");
    include("checksession.php");
    
        if(isset($_POST['action'])){
        $gname = $_POST['gname'];
        $gemail = $_POST['mail'];
        $gmsg = $_POST['gmsg'];
        $date = date("m.d.y");
$sql = "insert into tblguestbook ";
$sql .= "(guestname, guestemail, guestmessage, guestdate)";
$sql .=" values('$gname','$gemail','$gmsg','$date')";
    mysql_query($sql);
    }

?>


<html>
<head><title>My Guestbook</title>
<link href="styles/style.css" rel="stylesheet" />
<script language="javascript" src="includes/validate.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
    background-color: #000000;
}
-->
</style></head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="17%">&nbsp;</td>
    <td width="83%" valign="bottom" >&nbsp;</td>
  </tr>
</table>

<form name = "form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" onSubmit="return validateForm(form1)">
  <p class="fontSubTitle">Sign to Guestbook</p>
  <p class="fontSubTitle"><span class="fontText">Name: </span>
    <input type="text" name="gname">
    <br>
    <span class="fontText">Email:</span>
    <input name="mail" type="text" id="mail">
    <br>
    <span class="fontText">Message:</span>
    <textarea cols="35" rows="6" name="gmsg"></textarea>
  </p>
  <p class="fontSubTitle">
    <input type="submit" value="Send" name="action">
    <input name="reset" type="reset" value="Clear">
    <br>
  </p>
</form>
  <p>
    <?php
    $results = mysql_query("select * from tblguestbook order by guestid desc");

    while($data = mysql_fetch_object($results)){
    echo "<table width=\"500\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" class=\"borderThin\" >";
echo " <tr>\n";
echo "<td class=\"fontTextTwo\" align=\"left\" width=\"60%\">name: ";
echo "<a href=\"mailto:".$data->guestemail."\" class=\"b\">".$data->guestname."</a>";
echo "</td>\n";
            echo "<td class=\"fontTextTwo\" align=\"right\"  width=\"40%\">dated posted: ".$data->guestdate."</td>\n";
echo "  </tr>\n";
          echo "<tr>\n";
           echo " <td colspan=\"2\" class=\"fontText\" align=\"left\">".$data->guestmessage."</td>\n";
echo " </tr>\n";
echo "</table><br>";
    }
    
?>
</p>

</body>
</html>
<?php
    mysql_close($dbh);
?>

any help would be appreciated

 

 

 


Reply

jlhaslip
Google php pagination script

here is a link to Code Walkers. They have pretty solid scripts.
http://www.codewalkers.com/c/a/Link-Farm-Code/Pagination/

Reply

galexcd
I won't be as vague as grampa Jim was... Basically you'll want to add this bit of code to your sql query:

CODE
$results = mysql_query("select * from tblguestbook order by guestid desc LIMIT ".($rowsperpage*(is_numeric($_GET['page'])?($_GET['page']-1):0)).", ".($rowsperpage*(is_numeric($_GET['page'])?$_GET['page']:1)).";");


And then at the beginning define the variable "$rowsperpage"
CODE
$rowsperpage=5;


Reply

dvayne
QUOTE(alex7h3pr0gr4m3r @ Nov 26 2007, 09:52 AM) *
I won't be as vague as grampa Jim was... Basically you'll want to add this bit of code to your sql query:

CODE
$results = mysql_query("select * from tblguestbook order by guestid desc LIMIT ".($rowsperpage*(is_numeric($_GET['page'])?($_GET['page']-1):0)).", ".($rowsperpage*(is_numeric($_GET['page'])?$_GET['page']:1)).";");


And then at the beginning define the variable "$rowsperpage"
CODE
$rowsperpage=5;

where will I put $rowsperpage=5; ? before include("config/config.inc.php"); ?

 

 

 


Reply

pop
put it before you use it.

Reply

galexcd
Yeah anywhere before that sql query i told you to change is fine, but if I were you I'd put it at the begining of the file just incase you wanted to change how many rows per page are displayed quickly.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. display 10 records per page using jsp - 40.59 hr back. (1)
  2. "web page" and "javascripts" and validate.js - 170.19 hr back. (1)
  3. displaying 10 records/page - 566.92 hr back. (1)
Similar Topics

Keywords : displaying, 10, records, page

  1. Displaying Date And Time (gmt+8)
    (5)
  2. Displaying Your Phone Number On A Wap Site
    (3)
    I have a wap site elitezone.co.za and what i want to add is a code to the index page that displays
    your operator and phone number. Does any one know the coding for this function if so please show me
    here. Help will appriacated. Topic title modified. ....
  3. Displaying Files Of A Directory
    (2)
    I want to display the contents of a directory.. i have the following code.. It gives the output in
    one column only... like file1 file2 file3 file4 . . . . . Since there are lot of files so this
    column gets very long..i want to display the x number of files in each column.. like if there are 22
    files.. then file 1 file 11 file 21 file 2 . file 22 file 3 .. . . . file 10
    file 20 This was just an example..I know it can be done by using but i dont know how to do it
    with loop. Please help me. QUOTE $dir = './'; $handle =....
  4. Directory Files Displaying
    (5)
    I have many files in a directory..I want to create a page , like A B C D E F ..... when some one
    click on A , it should display all the files starting from letter A , and when clicks on B , it
    should show all the files in that directory starting from B , and so on... I have no idea how to
    display the files of the directory iin that way. Kindly assist me......
  5. Displaying Latest Added Files Of Subdirectories ?
    (5)
    For example,i have a directory , which has 3 sub directories a,b and c...and i have some files in
    all subdirectories.. is it possible that i can display the latest added files to any of sub
    directory a,b, or c.?i think i will have to use sort by date function but how it should be done that
    it compares the files of all the subdirectories directories ?....
  6. Php/mysql Search Engine Help
    Having issues displaying results (1)
    I've been using a tutorial
    (http://www.devarticles.com/c/a/MySQL/Developing-A-Site-Search-Engine-With-PHP-And-MySQL/) at this
    address to help me get started on building my own search engine. I've completed the tutorial but
    when I run the search, I get no results on the results page. I'm wondering if anyone will take a
    look at this script and see if they can figure out why my I'm not getting any results displayed.
    I'm using phpMyAdmin to build the database and simple notepad to build the PHP script. CODE
    <?php $submit = $_POST[&....

    1. Looking for displaying, 10, records, page

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for displaying, 10, records, page

*MORE FROM TRAP17.COM*
advertisement



Displaying 10 Records Per Page



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE