However, the layouts pages are connected to a php page which allows only a certain number of layouts per page and then creates new pages when the current ones are filled.
My question, in a nutshell, is how can I link the searched images to these pages which are created through php?
Here is the search engine code:
Quote
<center><form action="#results" method="post">
Type: <input type="text" name="type" size="30" maxlength="30"></p>
<p>Series: <select name="series">
<?php
mysql_connect("localhost","username","password");
mysql_select_db("databasename");
// List out the series in the database
$qSeries = "select series_id, series_name from layseries order by series_name ";
$rsSeries = mysql_query($qSeries) or die ('Cannot execute query');
while ($row = mysql_fetch_array($rsSeries))
{
extract($row);
echo '<option value="'.$series_id.'">'.$series_name.'></option>';
}
?>
</select>
</p>
<p><input type="submit" value="Search"></p>
</form></center>
<hr>
<p>Here are the <a name="results">results</A> of your search:
<p><?php
mysql_connect("localhost","username","password");
mysql_select_db("databasename");
// For global registers off
// ====================
$type = strtolower(strip_tags(mysql_escape_string($_POST['type'])));
$series = strip_tags(mysql_escape_string($_POST['series']));
$order = strip_tags(mysql_escape_string($_POST['order']));
// validate for empty type field
// Remove this if you wish to allow all type listing
if (empty($type))
{
die ('Please fill in a layout option.');
}
// Build search query
$qSearch = "select a.*, b.series_name from layouts a, layseries b where a.type LIKE '%$type%' and a.series_id='$series' and a.series_id=b.series_id order by a.date $order ";
$rsSearch = mysql_query($qSearch);
if (mysql_num_rows($rsSearch) == 0)
{
print '<p>Sorry, there was no results returned for your search. Please try again.</p>';
}
else
{
print '<p><strong>'.mysql_num_rows($rsSearch).'</strong> layout(s) found.</p>';
while ($row = mysql_fetch_array($rsSearch))
{
extract($row);
print '<table border="0" align="center" valign="top" cellpadding="7" cellspacing="2"><td>
<table bgcolor="#ADC6BC" style="border: 1px solid #000;"><tr>
<td><a href="'.$layout_url.'"><img src="http://i182.photobucket.com/albums/x165/Mind8/'.$layout_image.'" border="0" title="Layout" alt="Layout"></A></td>
<td style="border-left: 1px dotted #000; padding-left: 4px;">
<b>Title:</b>
<br><div class="indent">'.$layout_title.'</div>
<b>Series:</b>
<br><div class="indent">'.$series_name.'</div>
<b>Character(s):</b>
<br><div class="indent">'.$character.'</div>
<b>Type:</b>
<br><div class="indent">'.$type.'</div>
<b>Added:</b>
<br><div class="indent">'.$date.'</div>
</td>
</tr></table>
</td></table>';
}
}
?>
Type: <input type="text" name="type" size="30" maxlength="30"></p>
<p>Series: <select name="series">
<?php
mysql_connect("localhost","username","password");
mysql_select_db("databasename");
// List out the series in the database
$qSeries = "select series_id, series_name from layseries order by series_name ";
$rsSeries = mysql_query($qSeries) or die ('Cannot execute query');
while ($row = mysql_fetch_array($rsSeries))
{
extract($row);
echo '<option value="'.$series_id.'">'.$series_name.'></option>';
}
?>
</select>
</p>
<p><input type="submit" value="Search"></p>
</form></center>
<hr>
<p>Here are the <a name="results">results</A> of your search:
<p><?php
mysql_connect("localhost","username","password");
mysql_select_db("databasename");
// For global registers off
// ====================
$type = strtolower(strip_tags(mysql_escape_string($_POST['type'])));
$series = strip_tags(mysql_escape_string($_POST['series']));
$order = strip_tags(mysql_escape_string($_POST['order']));
// validate for empty type field
// Remove this if you wish to allow all type listing
if (empty($type))
{
die ('Please fill in a layout option.');
}
// Build search query
$qSearch = "select a.*, b.series_name from layouts a, layseries b where a.type LIKE '%$type%' and a.series_id='$series' and a.series_id=b.series_id order by a.date $order ";
$rsSearch = mysql_query($qSearch);
if (mysql_num_rows($rsSearch) == 0)
{
print '<p>Sorry, there was no results returned for your search. Please try again.</p>';
}
else
{
print '<p><strong>'.mysql_num_rows($rsSearch).'</strong> layout(s) found.</p>';
while ($row = mysql_fetch_array($rsSearch))
{
extract($row);
print '<table border="0" align="center" valign="top" cellpadding="7" cellspacing="2"><td>
<table bgcolor="#ADC6BC" style="border: 1px solid #000;"><tr>
<td><a href="'.$layout_url.'"><img src="http://i182.photobucket.com/albums/x165/Mind8/'.$layout_image.'" border="0" title="Layout" alt="Layout"></A></td>
<td style="border-left: 1px dotted #000; padding-left: 4px;">
<b>Title:</b>
<br><div class="indent">'.$layout_title.'</div>
<b>Series:</b>
<br><div class="indent">'.$series_name.'</div>
<b>Character(s):</b>
<br><div class="indent">'.$character.'</div>
<b>Type:</b>
<br><div class="indent">'.$type.'</div>
<b>Added:</b>
<br><div class="indent">'.$date.'</div>
</td>
</tr></table>
</td></table>';
}
}
?>
And here is the code for one of the pages I am trying to connect to (sorry if it's a complete mess):
Quote
<?php
$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("databasename");
$query = "select * from dlayouts order by layout_id desc ";
$result = mysql_query($query);
// Insert Code A Here
// dynamic navigation variables
$screen = $_GET['screen'];
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page=5;
$total_records=mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
if (!isset($screen))
$screen=0;
$start = $screen * $rows_per_page;
$query .= "LIMIT $start, $rows_per_page";
$result= mysql_query($query) or die
("Could not execute query : $query." . mysql_error());
$i=0; // set the column indicator
echo '<table border="0" align="center" valign="top" cellpadding="7" cellspacing="2">'; // open table tag here
while($row=mysql_fetch_array($result))
{
extract($row); // extract row values
$layout_url=$row["layout_url"];
$layout_name=$row["layout_name"];
$layout_image=$row["layout_image"];
$category=$row["category"];
$characters=$row["characters"];
$date=$row["date"];
$count_display=$row["count_display"];
$name_url=$row["name_url"];
if ($i==0)
{
echo "<tr><td>
<table align=\"center\">
<a name=\"$name_url\"></A>
<tr><td colspan=\"2\" class=\"name\">$layout_name</td>
<tr><td><table bgcolor=\"#ADC6BC\" style=\"border: 1px solid #000;\">
<tr><td>
<a href=\"graphics/$layout_url\" target=\"_blank\"><img src=\"http://i182.photobucket.com/albums/x165/Mind8/$layout_image\" border=\"0\" title=\"Layout\" alt=\"Layout\" /></A></td>
<td height=\"100\" width=\"140\" style=\"border-left: 1px dotted #000; padding-left: 4px;\">
<b>Series:</b><br /><div class=\"indent\">$category</div>
<b>Character(s):</b><br /><div class=\"indent\">$characters</div>
<b>Added:</b><br /><div class=\"indent\">$date</div>
</td></tr>
<tr><td colspan=\"2\" align=\"center\">[<a href=\"graphics/$layout_url\" target=\"_blank\">Preview</A>] [<a href=\"$layout_dl\" target=\"_blank\">Download</A> ($count_display)]</td></tr>
</table></table>
</td>";
}
}
echo '</table>'; // close table
// Put Code C Here
// create the dynamic links
if ($screen > 0) {
$j = $screen - 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">« Previous</a> | "; // I replaced the Prev with the « which is <<
}
// page numbering links now
$p = 5; // number of links to display per page
$lower = $p; // set the lower limit to $p
$upper = $screen+$p; // set the upper limit to current page + number of links per page
while($upper>$pages){
$p = $p-1;
$upper = $screen+$p;
}
if($p<$lower){
$y = $lower-$p;
$to = $screen-$y;
while($to<0){
$to++;
}
}
if(!empty($to))
{
for ($i=$to;$i<$screen;$i++){
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " <a href=\"$url\">[$j]</a> | ";
}
}
for ($i=$screen;$i<$upper;$i++) {
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " <a href=\"$url\">[$j]</a> | ";
}
if ($screen < $pages-1) {
$j = $screen + 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">Next »</a>"; // I replaced the Next with the » which is >>
}
?>
$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("databasename");
$query = "select * from dlayouts order by layout_id desc ";
$result = mysql_query($query);
// Insert Code A Here
// dynamic navigation variables
$screen = $_GET['screen'];
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page=5;
$total_records=mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
if (!isset($screen))
$screen=0;
$start = $screen * $rows_per_page;
$query .= "LIMIT $start, $rows_per_page";
$result= mysql_query($query) or die
("Could not execute query : $query." . mysql_error());
$i=0; // set the column indicator
echo '<table border="0" align="center" valign="top" cellpadding="7" cellspacing="2">'; // open table tag here
while($row=mysql_fetch_array($result))
{
extract($row); // extract row values
$layout_url=$row["layout_url"];
$layout_name=$row["layout_name"];
$layout_image=$row["layout_image"];
$category=$row["category"];
$characters=$row["characters"];
$date=$row["date"];
$count_display=$row["count_display"];
$name_url=$row["name_url"];
if ($i==0)
{
echo "<tr><td>
<table align=\"center\">
<a name=\"$name_url\"></A>
<tr><td colspan=\"2\" class=\"name\">$layout_name</td>
<tr><td><table bgcolor=\"#ADC6BC\" style=\"border: 1px solid #000;\">
<tr><td>
<a href=\"graphics/$layout_url\" target=\"_blank\"><img src=\"http://i182.photobucket.com/albums/x165/Mind8/$layout_image\" border=\"0\" title=\"Layout\" alt=\"Layout\" /></A></td>
<td height=\"100\" width=\"140\" style=\"border-left: 1px dotted #000; padding-left: 4px;\">
<b>Series:</b><br /><div class=\"indent\">$category</div>
<b>Character(s):</b><br /><div class=\"indent\">$characters</div>
<b>Added:</b><br /><div class=\"indent\">$date</div>
</td></tr>
<tr><td colspan=\"2\" align=\"center\">[<a href=\"graphics/$layout_url\" target=\"_blank\">Preview</A>] [<a href=\"$layout_dl\" target=\"_blank\">Download</A> ($count_display)]</td></tr>
</table></table>
</td>";
}
}
echo '</table>'; // close table
// Put Code C Here
// create the dynamic links
if ($screen > 0) {
$j = $screen - 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">« Previous</a> | "; // I replaced the Prev with the « which is <<
}
// page numbering links now
$p = 5; // number of links to display per page
$lower = $p; // set the lower limit to $p
$upper = $screen+$p; // set the upper limit to current page + number of links per page
while($upper>$pages){
$p = $p-1;
$upper = $screen+$p;
}
if($p<$lower){
$y = $lower-$p;
$to = $screen-$y;
while($to<0){
$to++;
}
}
if(!empty($to))
{
for ($i=$to;$i<$screen;$i++){
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " <a href=\"$url\">[$j]</a> | ";
}
}
for ($i=$screen;$i<$upper;$i++) {
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " <a href=\"$url\">[$j]</a> | ";
}
if ($screen < $pages-1) {
$j = $screen + 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">Next »</a>"; // I replaced the Next with the » which is >>
}
?>
If anyone can figure it out, I bow down to your php skills and will be very grateful for the help.
