Computer ForumsComputers  

Go Back   Computer Forums > Programmers Lounge > Programming Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 09-14-2003, 03:56 AM   #1 (permalink)
Monster Techie
 
Join Date: Nov 2002
Posts: 1,368
Send a message via AIM to shan
Default PHP Multi page script..

Hey all I gotta question on a script i'm working on....working example is @ http://www.shanb.com/events

Here's the script
PHP Code:
<?
mysql_connect
(localhost,'user','pass') or die ("No connection");
mysql_select_db('events') or die ("No database found!");
$query = ("SELECT * FROM pics WHERE picevent = '$pic_event' ORDER by picorder ASC");
$result mysql_query($query);
$numrows mysql_num_rows($result);
if(
$numrows=='0'){
echo 
"<tr><td colspan='2' align='center'>Sorry, no pictures for this event ( [b][i]<u>$pic_event</u>[/i][/b] )!!</td></tr>\n";
echo 
"<tr><td colspan='2' align='center'>Maybe I'll put them up sometime...</td></tr>\n";
}

for (
$cur 0$cur $numrows$cur++){
$row mysql_fetch_array($result);

echo 
"<tr><td>[url='viewimage.php?picture=$row[picname]'][img]./$row[picevent]/$row[picname][/img][/url]</td>\n";
echo 
"<td>$row[piccoments]</td>\n";
echo 
"</tr>\n";
}
mysql_close();
?>
What i want to do, is only display 10 pictures per page and have links on the bottom that are like page 1 page 2 page 3 and so on....anyone have any advice....
__________________

C:\\ Is the root of all evil




phiber@sysdum.com
spam this account, it's fun.
shan is offline   Reply With Quote
Old 09-14-2003, 05:37 AM   #2 (permalink)
Monster Techie
 
Join Date: Nov 2002
Posts: 1,368
Send a message via AIM to shan
Default

it's ok, i played around and figured it out, so here's what i did if anyone wants to know

PHP Code:
<?
if ($pg==''){
$pg 0;
}
$pagestart = ($pg*10);
$pageend = ($pagestart+10);
mysql_connect(localhost,'user','pass') or die ("No connection");
mysql_select_db('events') or die ("No database found!");

$cquery = ("SELECT * FROM pics WHERE picevent = '$pic_event'");
$cresult mysql_query($cquery);
$cnumrows ceil(mysql_num_rows($cresult)/10);

$query = ("SELECT * FROM pics WHERE picevent = '$pic_event' ORDER by picorder ASC LIMIT $pagestart,$pageend");
$result mysql_query($query);
$numrows mysql_num_rows($result);



if(
$numrows=='0'){
echo 
"<tr><td colspan='2' align='center'>Sorry, no pictures for this event ( [b][i]<u>$pic_event</u>[/i][/b] )!!</td></tr>\n";
echo 
"<tr><td colspan='2' align='center'>Maybe I'll put them up sometime...</td></tr>\n";
}

for (
$cur 0$cur $numrows$cur++){
$row mysql_fetch_array($result);

echo 
"<tr><td width='30%'>[url='viewimage.php?picture=$row[picname]'][img]./$row[picevent]/$row[picname][/img][/url]</td>\n";
echo 
"<td width='70%'>$row[piccoments]</td>\n";
echo 
"</tr>\n";
}
echo 
"<tr><td colspan='2' bgcolor='#FFFFFF' align='center'>";
echo 
"* [url='viewpics.php?pic_event=$pic_event']Start[/url] * ";
for (
$i $cnumrows $i ;$i++){
echo 
"[url='viewpics.php?pic_event=$pic_event&pg=$i']Page $i[/url] * ";
}
echo 
"</td></tr>";
echo 
"</td></tr>";
mysql_close();

?>

__________________

C:\\ Is the root of all evil




phiber@sysdum.com
spam this account, it's fun.
shan is offline   Reply With Quote
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:18 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0