Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 09-14-2003, 04:56 AM   #1 (permalink)
 
Monster Techie

Join Date: Nov 2002

Posts: 1,368

shan

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....
__________________
<center><h2><font color=\"red\">C:\\ Is the root of all evil</font></h2>
<hr width=\"50%\">
phiber@sysdum.com
spam this account, it's fun.
shan is offline  
Old 09-14-2003, 06:37 AM   #2 (permalink)
 
Monster Techie

Join Date: Nov 2002

Posts: 1,368

shan

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();

?>

__________________
<center><h2><font color=\"red\">C:\\ Is the root of all evil</font></h2>
<hr width=\"50%\">
phiber@sysdum.com
spam this account, it's fun.
shan is offline  
 
Closed Thread

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