Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 28th, 2006, 3:53 AM   #1
karmakiller
Newbie
 
Join Date: Feb 2006
Posts: 1
Rep Power: 0 karmakiller is on a distinguished road
Question pagination - display next page

Hi,
I am very new to php (three weeks) and i am trying to do a search database etc...

im doing ok ( i think...lol)

I am getting my results to show in the order i want now, but i want my results to show a max of 10 on each page... the problem is I dont know how to only show 10 results on one page and to have a next button that will show the next 10 and so on and so on.

please please could someone help as it is doig my head in! ive tried alsorts of examples and it just messes things up... can anyone edit my code and document it to show me how its done? i am really stuck

here is my code so far

[php]

<?php
mysql_connect (localhost, root, louvain);
mysql_select_db (directory);

if (empty($townorcounty))
{
$townorcounty = '%';
}

if (empty($county))
{
$county = '%';
}

$result = mysql_query ("SELECT * FROM `company` WHERE (`town` LIKE '$townorcounty%' OR `county` LIKE '$townorcounty%') ORDER BY package");

if (!mysql_num_rows($result))
{
print ('No search results');
}
else
{




print ('<table width="472" border="0" cellpadding="0" cellspacing="5" class="table">');
$ID = 0;
while ($row = mysql_fetch_array($result))
{
# Create the HTML image code.
//<a href="mailto:">email</a>
//<a href="http://www.">www.spacekitchens.co.uk</a>

$emailcode = '<a href="mailto:'.$row['emailaddress'].'"><img src="' . $row['email'] . '" alt="Click Here To Email" border="0" />';
$imgcode = '<a href="'.$row['website'].'"><img src="' . $row['photo'] . '" alt="Company Logo" border="0" />';
$webcode = '<a href="'.$row['website'].'"><img src="' . $row['websiteimg'] . '" alt="go to website" border="0" />';
$linecode = '<img src="' . $row['space'] . '" alt="go to website" border="0" />';
$today = date("d/m/Y - ");

//$variable1=$row["Company"];
//$variable2=$row["title"];
//$variable3=$row["county"];
//print ('<tr>');
//print ('<td><strong>');
//print ("$variable1");
//print ("$variable2");
//print ("$variable3");

print ('<td><strong>');
//print $today;
print $row['Company'];
print ('</strong>');
print $row['title'];
print('</td>');
print('</tr>');

print ('<tr>');
print ('<td>');
print $row['address'];
print $row['town'];
print $row['county'];
print $row['postcode'];
print('</td>');
print('</tr>');

print ('<tr>');
print ('<td>');
print $imgcode;
print('</td>');
print('</tr>');

print ('<tr>');
print ('<td>');
print $row['desc'];
print('</td>');
print('</tr>');

print ('<tr>');
print ('<td>');
print $emailcode;
print $webcode;
print('</td>');
print('</tr>');

print ('<tr>');
print ('<td>');
print $linecode;
print('</td>');
print('</tr>');

++$ID;
}
print ('</table>');

}
?>

[/php]
karmakiller is offline   Reply With Quote
Old Feb 28th, 2006, 5:18 AM   #2
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 399
Rep Power: 5 xavier is on a distinguished road
Send a message via Yahoo to xavier
http://www.phpfreaks.com/tutorials/43/0.php
Here's the first result on google. It won't kill you to search.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC