I am using following code to access image names from my database and would want to display them to the user page wise. But I am facing problem in making it page wise. Can any ne help me to solve my problem?
Thanks in advance.
/* Startimgcalls.php ----------
Through this I am giving choice to the user to select his option of images. */
<head><title>Textronics Design Systems</title></head>
<style type="text/css">
.bg{background:teal;color:yellow;}
.bg1{text:red;}
</style>
<body bgcolor="ivory">
<?php
$newfile = "";
$newlink = "";
?>
<h1 align="center"><?php echo(COMPANY); ?></h1><br><br>
<h3 align="center">Design Library</h3><br><br>
<form name="frmviewimg" action="viewrcpagewise.php" method=post>
<center>
<table><tr>
<?
mysql_connect();
mysql_select_db(software);
$result = mysql_query("SELECT * FROM mainlib");
?><td><?echo ("Select From Library :");?></td>
<td><select name="mainsele">
<? while ($i = mysql_fetch_object($result)) {
$mainopt = $i->newlibrary;
$maincode = $i->idmain;
?>
<option value=http://www.phpbuilder.com/board/archive/index.php/<?echo($maincode)?>><?echo($mainopt)?></option>
<? } ?></td><td>
<? mysql_connect();
mysql_select_db(software);
$result = mysql_query("SELECT * FROM undrlib");
//echo mysql_errno().": ".mysql_error()."<BR>";
?><td><?echo ("Select From Category :");?></td>
<td><select name="subsele">
<? while ($j = mysql_fetch_object($result)) {
$subopt = $j->newcategory;
$subcode = $j->idcat;
?>
<option value=<?echo($subcode)?>><?echo($subopt)?></option>
<? } ?></td>
<td><input type="submit" value="View Images"></td>
</tr></table>
</table>
</center>
</form>
</body>
/* viewrcpagewise.php -------
Through this I am showing images to the user */
<?php
include "./common_db.inc";
function list_records($ml,$sl)
{ global $records_per_page,$records_per_row;
global $cur_page;
global $PHP_SELF;
$records_per_row = 1;
db_connect();
$query = "SELECT count(*) FROM dsgnlib where idmain = $ml AND idcat = $sl";
$result = mysql_query($query);
$query_data = mysql_fetch_row($result);
$total_num_user = $query_data[0];
$page_num = $cur_page + 1;
$total_num_page = $last_page_num
= ceil($total_num_user/$records_per_page);
echo "<CENTER><H3>$total_num_user records found. Displaying the page
$page_num out of $last_page_num.</H3></CENTER>\n";
if(empty($cur_page)) {
$cur_page = 0;
}
$limit_str = "LIMIT ". $cur_page * $records_per_page .
", $records_per_page";
$query = "SELECT smallthumblink, bigimageanddesc FROM dsgnlib where idmain = $ml AND idcat = $sl $limit_str";
$result = mysql_query($query);
?>
<DIV ALIGN="CENTER">
<TABLE><TR>
<?php
while($query_data = mysql_fetch_array($result))
{ $smallthumblink = $query_data["smallthumblink"];
$bigimageanddesc = $query_data["bigimageanddesc"];?>
<td width=100 height=100 title="<?php echo($smallthumblink)?>"><a href="<?php echo($bigimageanddesc)?>"><img src=<?php echo($smallthumblink)?> onClick="f3()"></a></td>
<?
$records_per_row++;
if ($records_per_row > 3)
{ echo "</TR>\n";
$records_per_row = 1;
}
}
?>
</TABLE>
</DIV>
<?php
echo "<BR>\n";
echo "<STRONG><CENTER>";
if($page_num > 1)
{ $prev_page = $cur_page - 1;
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=0\">[Top]</A>";
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=$prev_page\">[Prev]</A> ";
}
if($page_num < $total_num_page)
{ $next_page = $cur_page + 1;
$last_page = $total_num_page - 1;
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=$next_page\">[Next]</A> ";
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=$last_page\">[Bottom]</A>";
}
echo "</STRONG></CENTER>";
}
list_records($ml,$sl);
?>
/* Common_db.inc -------
To include general routines */
<?php
$records_per_page = 6;
$records_per_row = 3;
global $ml,$sl;
$ml = $mainsele;
$sl = $subsele;
function db_connect()
{ mysql_connect();
mysql_select_db("software");
}
?>
Thanks in advance.
/* Startimgcalls.php ----------
Through this I am giving choice to the user to select his option of images. */
<head><title>Textronics Design Systems</title></head>
<style type="text/css">
.bg{background:teal;color:yellow;}
.bg1{text:red;}
</style>
<body bgcolor="ivory">
<?php
$newfile = "";
$newlink = "";
?>
<h1 align="center"><?php echo(COMPANY); ?></h1><br><br>
<h3 align="center">Design Library</h3><br><br>
<form name="frmviewimg" action="viewrcpagewise.php" method=post>
<center>
<table><tr>
<?
mysql_connect();
mysql_select_db(software);
$result = mysql_query("SELECT * FROM mainlib");
?><td><?echo ("Select From Library :");?></td>
<td><select name="mainsele">
<? while ($i = mysql_fetch_object($result)) {
$mainopt = $i->newlibrary;
$maincode = $i->idmain;
?>
<option value=http://www.phpbuilder.com/board/archive/index.php/<?echo($maincode)?>><?echo($mainopt)?></option>
<? } ?></td><td>
<? mysql_connect();
mysql_select_db(software);
$result = mysql_query("SELECT * FROM undrlib");
//echo mysql_errno().": ".mysql_error()."<BR>";
?><td><?echo ("Select From Category :");?></td>
<td><select name="subsele">
<? while ($j = mysql_fetch_object($result)) {
$subopt = $j->newcategory;
$subcode = $j->idcat;
?>
<option value=<?echo($subcode)?>><?echo($subopt)?></option>
<? } ?></td>
<td><input type="submit" value="View Images"></td>
</tr></table>
</table>
</center>
</form>
</body>
/* viewrcpagewise.php -------
Through this I am showing images to the user */
<?php
include "./common_db.inc";
function list_records($ml,$sl)
{ global $records_per_page,$records_per_row;
global $cur_page;
global $PHP_SELF;
$records_per_row = 1;
db_connect();
$query = "SELECT count(*) FROM dsgnlib where idmain = $ml AND idcat = $sl";
$result = mysql_query($query);
$query_data = mysql_fetch_row($result);
$total_num_user = $query_data[0];
$page_num = $cur_page + 1;
$total_num_page = $last_page_num
= ceil($total_num_user/$records_per_page);
echo "<CENTER><H3>$total_num_user records found. Displaying the page
$page_num out of $last_page_num.</H3></CENTER>\n";
if(empty($cur_page)) {
$cur_page = 0;
}
$limit_str = "LIMIT ". $cur_page * $records_per_page .
", $records_per_page";
$query = "SELECT smallthumblink, bigimageanddesc FROM dsgnlib where idmain = $ml AND idcat = $sl $limit_str";
$result = mysql_query($query);
?>
<DIV ALIGN="CENTER">
<TABLE><TR>
<?php
while($query_data = mysql_fetch_array($result))
{ $smallthumblink = $query_data["smallthumblink"];
$bigimageanddesc = $query_data["bigimageanddesc"];?>
<td width=100 height=100 title="<?php echo($smallthumblink)?>"><a href="<?php echo($bigimageanddesc)?>"><img src=<?php echo($smallthumblink)?> onClick="f3()"></a></td>
<?
$records_per_row++;
if ($records_per_row > 3)
{ echo "</TR>\n";
$records_per_row = 1;
}
}
?>
</TABLE>
</DIV>
<?php
echo "<BR>\n";
echo "<STRONG><CENTER>";
if($page_num > 1)
{ $prev_page = $cur_page - 1;
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=0\">[Top]</A>";
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=$prev_page\">[Prev]</A> ";
}
if($page_num < $total_num_page)
{ $next_page = $cur_page + 1;
$last_page = $total_num_page - 1;
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=$next_page\">[Next]</A> ";
echo "<A HREF=\"$PHP_SELF?list_records(ml,sl)&cur_page=$last_page\">[Bottom]</A>";
}
echo "</STRONG></CENTER>";
}
list_records($ml,$sl);
?>
/* Common_db.inc -------
To include general routines */
<?php
$records_per_page = 6;
$records_per_row = 3;
global $ml,$sl;
$ml = $mainsele;
$sl = $subsele;
function db_connect()
{ mysql_connect();
mysql_select_db("software");
}
?>