0810
12-02-2002, 10:17 PM
hi how are you doing?
What I am doing is that my database is so big so that I would like to show my results 5 each. Let's say I have 20 pictures in my database. Then I would like to show up 5 pictures in each page. It will be 4 pages. First page 5 pictures then when I click Next link,it goes to Next page which is 2page(6-10pic).3page(11-15 pic) and 4page(16-20pic).
I tried my scritp but it doesn't work at all
Here is script. my php is 4.23
<?php
if(!isset($_POST['searchtype']) || !isset($_POST['searchterm']))
{
echo"you have not entered search details. Please go back and try again.";
exit;
}
else
{
$searchtype = $_POST["searchtype"];
$searchterm = $_POST["searchterm"];
}
trim($searchterm);
$dbconnect = mysql_connect("localhost", "itohideo_hide", "0810");
if (!$dbconnect) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! mysql_select_db("itohideo_japan") ) {
echo( "<p>Unable to locate the host " .
"database at this time.</p>" );
exit();
}
$PHP_SELF = $_SERVER["SCRIPT_NAME"];
if($searchterm==""){
exit("You should specify your request<a href=\"lookforgirl.html\">Go Back</a>");
}
else{
$sql = "SELECT * FROM girls WHERE " . $searchtype . " LIKE '%" . $searchterm . "%'";
$result = mysql_query($sql);
$num_results = mysql_num_rows($result);
if (isset($_GET["page"]))
{
$page = $_GET["page"];
}
else {
$page = 1;
}
if($page>10)
{
$page = 10;
}
print($page."Page<br><br>\n");
echo("<p>itohideo.com found: " . $num_results . "</p>");
for($i=1; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo"<table border=0 cellpadding=5 cellspacing=3 width=50% align=center>";
echo"<tr>";
echo"<td width=70% align=right>";
echo "No.".($page-1)*10+$i.".Name: ";
echo htmlspecialchars( stripslashes($row["name"]));
echo"</td>";
echo"<td valign=top rowspan=3 align=right>";
echo"<img src=\"$row[images]\" width=180 height=160>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Country: ";
echo htmlspecialchars( stripslashes($row["country"]));
echo"</td>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Age:";
echo htmlspecialchars( stripslashes($row["age"]));
echo"<td>";
echo "</tr>";
echo"<table>";
}
if($page != 1)
{
print("<a href=\"$PHP_SELF?page=" . ($page -1) . "\">Privious Page</a>");
}
print(" ");
if($page != 10){
print("<a href=\"$PHP_SELF?page=" . ($page + 1) . "\">Next Page</a>");
}
echo ("<br>\n");
}
?>
What I am doing is that my database is so big so that I would like to show my results 5 each. Let's say I have 20 pictures in my database. Then I would like to show up 5 pictures in each page. It will be 4 pages. First page 5 pictures then when I click Next link,it goes to Next page which is 2page(6-10pic).3page(11-15 pic) and 4page(16-20pic).
I tried my scritp but it doesn't work at all
Here is script. my php is 4.23
<?php
if(!isset($_POST['searchtype']) || !isset($_POST['searchterm']))
{
echo"you have not entered search details. Please go back and try again.";
exit;
}
else
{
$searchtype = $_POST["searchtype"];
$searchterm = $_POST["searchterm"];
}
trim($searchterm);
$dbconnect = mysql_connect("localhost", "itohideo_hide", "0810");
if (!$dbconnect) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! mysql_select_db("itohideo_japan") ) {
echo( "<p>Unable to locate the host " .
"database at this time.</p>" );
exit();
}
$PHP_SELF = $_SERVER["SCRIPT_NAME"];
if($searchterm==""){
exit("You should specify your request<a href=\"lookforgirl.html\">Go Back</a>");
}
else{
$sql = "SELECT * FROM girls WHERE " . $searchtype . " LIKE '%" . $searchterm . "%'";
$result = mysql_query($sql);
$num_results = mysql_num_rows($result);
if (isset($_GET["page"]))
{
$page = $_GET["page"];
}
else {
$page = 1;
}
if($page>10)
{
$page = 10;
}
print($page."Page<br><br>\n");
echo("<p>itohideo.com found: " . $num_results . "</p>");
for($i=1; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo"<table border=0 cellpadding=5 cellspacing=3 width=50% align=center>";
echo"<tr>";
echo"<td width=70% align=right>";
echo "No.".($page-1)*10+$i.".Name: ";
echo htmlspecialchars( stripslashes($row["name"]));
echo"</td>";
echo"<td valign=top rowspan=3 align=right>";
echo"<img src=\"$row[images]\" width=180 height=160>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Country: ";
echo htmlspecialchars( stripslashes($row["country"]));
echo"</td>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Age:";
echo htmlspecialchars( stripslashes($row["age"]));
echo"<td>";
echo "</tr>";
echo"<table>";
}
if($page != 1)
{
print("<a href=\"$PHP_SELF?page=" . ($page -1) . "\">Privious Page</a>");
}
print(" ");
if($page != 10){
print("<a href=\"$PHP_SELF?page=" . ($page + 1) . "\">Next Page</a>");
}
echo ("<br>\n");
}
?>