pagination in css/php - php

two questions:
--1-- it displays all the number of pages. but i'd like it to display as:
<< Prev . . 3 4 [5] 6 7 . . Next >>
--2-- when i hover on the current page no, it should change color or increase the font-size, but when i modify the css of a:hover, all the page nos change color or size instead of the one which i'm pointing to. also, when modifying a:active, nothing happens.
this is my paging code in php:
$self = $_SERVER['PHP_SELF'];
$limit = 2; //Number of results per page
$numpages=ceil($totalrows/$limit);
$query = $query." ORDER BY idQuotes LIMIT " . ($page-1)*$limit . ",$limit";
$result = mysql_query($query, $conn)
or die('Error:' .mysql_error());
?>
<div class="caption">Search Results</div>
<div class="center_div">
<table>
<?php while ($row= mysql_fetch_array($result, MYSQL_ASSOC)) {
$cQuote = highlightWords(htmlspecialchars($row['cQuotes']), $search_result);
?>
<tr>
<td style="text-align:right; font-size:15px;"><?php h($row['cArabic']); ?></td>
<td style="font-size:16px;"><?php echo $cQuote; ?></td>
<td style="font-size:12px;"><?php h($row['vAuthor']); ?></td>
<td style="font-size:12px; font-style:italic; text-align:right;"><?php h($row['vReference']); ?></td>
</tr>
<?php } ?>
</table>
</div>
<div class="searchmain">
<?php
//Create and print the Navigation bar
$nav="";
$next = $page+1;
$prev = $page-1;
if($page > 1) {
$nav .= "<span class=\"searchpage\"><a onclick=\"showPage('','$prev'); return false;\" href=\"$self?page=" . $prev . "&q=" .urlencode($search_result) . "\">< Prev</a></span>";
$first = "<span class=\"searchpage\"><a onclick=\"showPage('','1'); return false;\" href=\"$self?page=1&q=" .urlencode($search_result) . "\"> << </a></span>" ;
}
else {
$nav .= " ";
$first = " ";
}
for($i = 1 ; $i <= $numpages ; $i++) {
if($i == $page) {
$nav .= "<span class=\"searchpage\">$i</span>";
}else{
$nav .= "<span class=\"searchpage\"><a onclick=\"showPage('',$i); return false;\" href=\"$self?page=" . $i . "&q=" .urlencode($search_result) . "\">$i</a></span>";
}
}
if($page < $numpages) {
$nav .= "<span class=\"searchpage\"><a onclick=\"showPage('','$next'); return false;\" href=\"$self?page=" . $next . "&q=" .urlencode($search_result) . "\">Next ></a></span>";
$last = "<span class=\"searchpage\"><a onclick=\"showPage('','$numpages'); return false;\" href=\"$self?page=$numpages&q=" .urlencode($search_result) . "\"> >> </a></span>";
}
else {
$nav .= " ";
$last = " ";
}
echo $first . $nav . $last;
?>
</div>
and this is how it displays currently:
alt text http://img714.imageshack.us/img714/7184/pag1l.jpg
css:
.searchmain {
margin:30px;
text-align: center;
}
.searchpage {
border: solid 1px #ddd;
background: #fff;
text-align:left;
font-size: 16px;
padding:9px 12px;
color: #FEBE33;
margin-left:2px;
}
.searchpage a{
text-decoration: none;
color: #808080;
}
.searchpage a:hover {
color: #FEBE33;
border-color: #036;
text-decoration: none;
}
.searchpage a:visited {
color: #808080;
}

The solution to your first program seems pretty straightforward; you know the number of surrounding links you want to display so you can simply loop from current_page - surrounding_links to current_page + surrounding_links. Add some conditions for the beginning, the end and for when to show the dots and you're done.
For the css; I´m not entirely sure what you want to achieve but I think you can solve it by using just a tags, the surrounding spans seem redundant, you only need them for the items that are not links (.no_link in the example below):
a, .no_link {
float: left;
display: block;
padding:9px 12px;
border: solid 1px #ddd;
background: #fff;
text-align:left;
font-size: 16px;
}
a {
color: #808080;
}
a:hover {
color: #FEBE33;
border-color: #036;
}
.no_link {
color: #FEBE33;
}

1. Change the padding and border properties of this CSS:
.searchpage {
border: none;
background: #fff;
text-align:left;
font-size: 16px;
padding:3px;
color: #FEBE33;
margin-left:2px;
}
And add the codes for square brackets around $i.
for($i = 1 ; $i <= $numpages ; $i++) {
if($i == $page) {
$nav .= "<span class=\"searchpage\">[$i]</span>";
That should change the visuals of your numbers, I haven't tested it seeing as you don't have a live site but it should work.
2. Instead of .searchpage a:hover try searchmain a:hover.
None of this is tested, but best I could come up with after viewing your code. Hope it helps to at least point you in the right direction :)

Related

How to show pagination series with dot in php?

code:
<?php
$sql = "SELECT COUNT(*) FROM attandance";
$retval1 = mysqli_query($con, $sql);
$row = mysqli_fetch_row($retval1);
$total_records = $row[0];
$total_pages = ceil($total_records / $limit);
echo "<ul class='pagination'>";
echo "<li><a href='index.php?page=".($page)."' class='button'>Previous</a></li>";
for ($i=1; $i<=$total_pages; $i++) {
echo "<li><a href='index.php?page=".$i."'>".$i."</a></li>";
}
echo "<li><a href='index.php?page=".($page+1)."' class='button'>NEXT</a></li>";
echo "</ul>";
?>
I have create a pagination in php now its work fine but pagination series look like previous 1234567891011121314151617181920 next like this but I want like
Previous 1 2 3 4 5 . . . . 20 next. So, How can I do this ?Please help me.
Thank You
Here is some helpful code for you, please check this.
<?php
// Please place your select query over here.
// $sql = "SELECT COUNT(*) FROM attandance";
// $retval1 = mysqli_query($con, $sql);
// $row = mysqli_fetch_row($retval1);
// $total_records = $row[0];
$page = ((isset($_GET['page'])) && ($_GET['page'] != ''))? $_GET['page'] : 1;
echo "You are on Page: ".$page;
$limit = 5; // I'm all this as static, please change it
$total_records = 34; // I'm all this as static, please change it to `$row[0]`
$total_pages = ceil($total_records / $limit);
echo "<ul class='pagination'>";
if ($page > 1)
echo "<li><a href='index.php?page=".($page - 1)."' class='button'>PREVIOUS</a></li>";
$show = 0;
for ($i = $page; $i <= $total_pages; $i++) {
$show++;
if ($page == $i)
echo "<li class='active'>".$i."</li>";
else if (($show < 5) || ($total_pages == $i))
echo "<li><a href='index.php?page=".$i."'>".$i."</a></li>";
else
echo "<li class='dot'>.</li>";
}
if ($total_pages > $page)
echo "<li><a href='index.php?page=".($page + 1)."' class='button'>NEXT</a></li>";
echo "</ul>";
?>
If you need some CSS, try using:
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
li.active {
display: block;
color: red;
text-align: center;
padding: 16px;
text-decoration: none;
}
li.dot {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
</style>

Including check box to each row of my data in database using php and html

I have a table called idean5 which has my data.And i'm displaying that data using php on my webpage ,now i want to add a tick box for each row of my data,actually i want to move particular rows from this table idean5 to other table called idean4. so when some one ticks the boxes and click on a move hyperlink button.this data should be moved.
code for this:
<?php
include('db.php');
require_once('auth.php'); //include of db config file
include ('paginate.php'); //include of paginat page
$per_page = 15; // number of results to show per page
$result = mysql_query("SELECT * FROM idean5");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);//total pages we going to have
//-------------if page is setcheck------------------//
if (isset($_GET['page'])) {
$page = intval($_GET['page']);
if ($page <= 0){
$page = 1;}
$show_page = $_GET['page']; //it will telles the current page
if ($show_page > 0 && $show_page <= $total_pages) {
$start = ($show_page - 1) * $per_page;
$end = $start + $per_page;
} else {
// error - show first set of results
$start = 0;
$end = $per_page;
}
} else {
// if page isn't set, show first set of results
$start = 0;
$end = $per_page;
}
// display pagination
$tpages=$total_pages;
?>
<!DOCTYPE html>
<html>
<head>
<style>
body { background: #eee url() no-repeat center 0px; padding-top:5px;}
ul {
list-style-type: none;
margin: center;
padding: center;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: green;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<style type="text/css">
.logo
{
text-align: center;
}
.container{
}
</style>
<h3 align="right">WELCOME <?php echo $_SESSION['SESS_FIRST_NAME'];?>!</h3>
</head>
<body>
<ul>
<li>REQUEST FOR TND</li>
<li class="dropdown">
UPLOAD TND
<div class="dropdown-content">
TND REQUESTS
UPLOAD TND
</div>
</li>
<li>STATUS SEARCH</li>
<li>SEARCH</li>
<li>APPROVAL</li>
<li>LOGOUT</li>
</ul>
<div class="container">
<div class="row">
<div class="logo">
</a>
</div>
</div>
<div class="row">
<?php
$reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages;
echo '<div class="pagination"><ul>';
if ($total_pages > 1) {
echo paginate($reload, $show_page, $total_pages);
}
echo "</ul></div>";
// display data in table
echo "<table border='1'>
<tr>
<th>TND ID</th>
<th>Site Name S1</th>
<th>Site Name S2</th>
<th>Idea ID S1</th>
<th>Idea ID S2</th>
<th>O N M Remarks</th>
<th>Planning Remarks</th>
<th>Projects Remarks</th>
</tr>";
// loop through results of database query, displaying them in the table
for ($i = $start; $i < $end; $i++) {
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) {
break;
}
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . mysql_result($result, $i, 'TND_ID') . '</td>';
echo '<td>' . mysql_result($result, $i, 'Site_name_S1') . '</td>';
echo '<td>' . mysql_result($result, $i, 'Site_name_S2') . '</td>';
echo '<td>' . mysql_result($result, $i, 'Idea_ID_S1') . '</td>';
echo '<td>' . mysql_result($result, $i, 'Idea_ID_S2') . '</td>';
if (mysql_result($result, $i, 'O_M_Remarks')) {
echo '<td>' . mysql_result($result, $i, 'O_M_Remarks').'</td>';
}
else {
echo '<td>' . mysql_result($result, $i, 'O_M_Remarks') . 'O N M remarks </td>';
}
if (mysql_result($result, $i, 'Planning_Remarks')) {
echo '<td>' . mysql_result($result, $i, 'Planning_Remarks').'</td>';
}
else {
echo '<td>' . mysql_result($result, $i, 'Planning_Remarks') . 'Planning remarks </td>';
}
if (mysql_result($result, $i, 'O_M_Remarks')) {
echo '<td>' . mysql_result($result, $i, 'Projects_Remarks').'</td>';
}
else {
echo '<td>' . mysql_result($result, $i, 'Projects_Remarks') . 'Projects remarks </td>';
}
echo "</tr>";
}
// close table>
echo "</table>";
// pagination
?>
</div>
</div>
</div>
</div>
</body>
</html>
In "//echo out the contents of each row into a table" portion. try this at this.
<td>input type="checkbox"></td>
For loop will automatically add checkbox in each row.

How do I place text in table with css and how to fix footer

What I want to do:
I want in each box, to be shown some data from database.
I've made a table which display it in 2 rows.. but I have some problems with CSS I guess.
My second problem is the footer. I want to make it so that it doesn't overlap the table when more results from the database are shown, but still don't know how.
I try with and without absolute position, etc but it's still mess.
CSS
#infobox h1 {
color: brown;
left: 90px;
top: 50px;
font-size: 13px;
}
#infobox p {
color: brown;
left: 160px;
top: 95px;
font-size: 13px;
}
=====================================
PHP
<table style ="position:absolute; left:0px">
<tbody>
<?php
$i = 1;
$columns = 2;
$data1 = mysql_query("SELECT * FROM `stuff` WHERE categorie='1' AND nr_redeems='0' ") or die(mysql_error());
while($row1 = mysql_fetch_array($data1))
{
if($i == 1){ echo '<tr>'; }
echo "<td id='infobox'>" . "<div class=''></div>"
. "<img style='position:relative; top:0px; left:0px; width:423px; height:121px' src='../img/button.gif'>"
. "<h1>Some data about it.</h1>"
. "<p><b>Price:"
. $row1['nr_points']
. "points</b></p>"
. "</td>";
$i++;
if($i == ($columns + 1)) { echo '</tr>'; $i = 1; }
}
?>
</tbody>
</table>
=====================================

How can I insert pagination in my search engine?

How can I insert pagination in my search engine search.php page?
If there is 1 page, I do not want the Previous button and the Next button.
If there are 2 pages and I am on the first page, I hope that I can have the Next button.
If there are 2 pages and I am on the second page, I also hope that I can only have the Previous button.
This is my current code, hope that you can help me:
<?php
//php code goes here
include 'connect.php'; // for database connection
include 'script_suggestion.php';
include 'script_close_suggestion_box.php';
$query = $_GET['q']; // query
$button = $_GET ['submit'];
$page_number = $_GET['page'];
if (!$page_number);
$page_number = 0;
$results_per_page = 10;
$next = $page_number + $results_per_page;
$prev = $page_number - $results_per_page;
?>
<html>
<head>
<title>
Brandon's Search Engine
</title>
<style type="text/css">
#title a {
font-size: 17pt;
margin: 5px;
padding: 2px;
border-color: black;
text-decoration: underline;
width: 544px;
}
#search-result {
display: block;
border: 1px solid grey;
border-color: grey;
}
#search-result:hover {
background-color: #dddddd;
width: 544px;
}
#link {
font-size: 17pt;
margin: 5px;
padding: 2px;
width: 544px;
}
#description {
font-size: 17pt;
margin: 5px;
padding: 2px;
width: 544px;
}
#search-page-number {
display: block;
width: auto;
height: auto;
border: 1px solid gray;
margin: 2px;
padding-left: 5px;
padding-right: 5px;
padding-bottom: 2px;
padding-top: 2px;
list-style: none;
float: left;
text-align: center;
}
#search-page-number:hover {
background-color: #dddddd;
}
#suggestion {
border: 1px solid black;
visibility: hidden;
position: fixed;
background-color: white;
z-index: 10;
}
#suggestion a {
font-size: 12pt;
color: black;
text-decoration: none;
display: block;
width: 548px;
height: auto;
text-align: left;
padding: 2px;
}
#suggestion a:hover {
background-color: #dddddd;
width: 544px;
padding: 2px;
}
</style>
</head>
<body>
<form method="GET" action="search.php">
<table>
<tr>
<td>
<h2>
Brandon's Search Engine
</h2>
</td>
</tr>
<tr>
<td>
<input type="text" value="<?php echo htmlspecialchars($_GET['q']); ?>" name="q" style="height: 27px; width: 550px; padding: 2px" name="q"
onkeyup="getSuggestion(this.value)" autocomplete="off" onblur="closeBox()" placeholder="Search Now"/>
<input type="submit" value="Search" name="submit" style="height: auto; width: 60px; padding: 2px" />
<div id="suggestion" style="width: 548px">
</div>
</td>
</tr>
</table>
<br>
<hr>
<table>
<tr>
<td>
<?php
//SQL query
$stmt = "SELECT * FROM searchengine WHERE title LIKE '%" . mysqli_real_escape_string($con,$query) . "%' OR keywords LIKE '%" . mysqli_real_escape_string($con,$query) . "%' OR link LIKE '%" . mysqli_real_escape_string($con,$query) . "%' LIMIT " . $page_number . " , $results_per_page";
$result = mysqli_query($con,$stmt) or die(mysqli_error($con));
$number_of_result = mysqli_num_rows($result);
$x++;
if($x==1)
if ($number_of_result < 1) {
echo "<b>No results found!</b>";
echo "<p>";
echo "Your search - <b>$query</b>" . " - did not match any documents. Please try different keywords.";
} elseif ($number_of_result > 1) {
echo "<b>$number_of_result results found!</b>";
echo "<p>";
//results found here and display them
$index = 1;
while (($row = \mysqli_fetch_assoc($result)) && ($index < 10)) {//10 results per page
$title = $row["title"];
$description = $row["description"];
$link = $row["link"];
echo "<div id='search-result'>";
echo "<div id='title'><a href='$link'>" . $title . "</a></div>";
//echo "<br />";
echo "<div id='link'><small>" . $link . "</small></div>";
//echo "<p>";
echo "<div id='description'><small>" . $description . "</small></div>";
echo "</div>";
echo "<br />";
$index++;
}
} elseif ($number_of_result = 1) {
echo "<b>$number_of_result result found!</b>";
echo "<p>";
//results found here and display them
$index = 1;
while (($row = \mysqli_fetch_assoc($result)) && ($index < 10)) {//10 results per page
$title = $row["title"];
$description = $row["description"];
$link = $row["link"];
echo "<div id='search-result'>";
echo "<div id='title'><a href='$link'>" . $title . "</a></div>";
//echo "<br />";
echo "<div id='link'><small>" . $link . "</small></div>";
echo "<br />";
echo "<div id='description'><small>" . $description . "</small></div>";
echo "</div>";
echo "<br />";
$index++;
}
}
?>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="page" value="<?php echo 1; ?>" />
<div id="page-number">
Select Page Number:
<?php
//ie if 35 results are therer then we require 4 pages that are 0 to max_page_number
//current page number is equal to page_number
$max_page_number = $number_of_result / 10;
//echo $max_page_number;
echo "<ul>";
//both the condition are not the neccesary
if(!$page_number <= 0)
{
//print the link to previous page
echo "<li id='search-page-number'>";
echo "Previous";
echo "</li>";
}
$i = 1;
for($index = 0; $index < $number_of_result; $index=$index+$results_per_page)
{
echo "<li id='search-page-number'>";
echo "<a href=search.php?q=$query&page=$i>";
echo $i++ . "</a>";
echo "</li>";
}
if($page_number < $number_of_result - $results_per_page)
{
//print the link to next page
echo "<li id='search-page-number'>";
echo "Next";
echo "</li>";
}
echo "</ul>";
?>
</div>
</td>
</tr>
<tr>
<td align="center">
To insert your site in result fill in the form at here.
</td>
</tr>
</table>
</form>
</body>
</html>
Thanks in advance.
<?php
//php code goes here
include 'connect.php'; // for database connection
include 'script_suggestion.php';
include 'script_close_suggestion_box.php';
$query = $_GET['q']; // query
$button = $_GET ['submit'];
$page_number = (int)$_GET['page'];
if (!$page_number)
$page_number = 0;
$results_per_page = 10;
$next = $page_number + $results_per_page;
$prev = $page_number - $results_per_page;
?>
<html>
<head>
<title>
Brandon's Search Engine
</title>
<style type="text/css">
#title a {
font-size: 17pt;
margin: 5px;
padding: 2px;
border-color: black;
text-decoration: underline;
width: 544px;
}
#search-result {
display: block;
border: 1px solid grey;
border-color: grey;
}
#search-result:hover {
background-color: #dddddd;
width: 544px;
}
#link {
font-size: 17pt;
margin: 5px;
padding: 2px;
width: 544px;
}
#description {
font-size: 17pt;
margin: 5px;
padding: 2px;
width: 544px;
}
#search-page-number {
display: block;
width: auto;
height: auto;
border: 1px solid gray;
margin: 2px;
padding-left: 5px;
padding-right: 5px;
padding-bottom: 2px;
padding-top: 2px;
list-style: none;
float: left;
text-align: center;
}
#search-page-number:hover {
background-color: #dddddd;
}
#suggestion {
border: 1px solid black;
visibility: hidden;
position: fixed;
background-color: white;
z-index: 10;
}
#suggestion a {
font-size: 12pt;
color: black;
text-decoration: none;
display: block;
width: 548px;
height: auto;
text-align: left;
padding: 2px;
}
#suggestion a:hover {
background-color: #dddddd;
width: 544px;
padding: 2px;
}
</style>
</head>
<body>
<form method="GET" action="search.php">
<table>
<tr>
<td>
<h2>
Brandon's Search Engine
</h2>
</td>
</tr>
<tr>
<td>
<input type="text" value="<?php echo htmlspecialchars($_GET['q']); ?>" name="q" style="height: 27px; width: 550px; padding: 2px" name="q"
onkeyup="getSuggestion(this.value)" autocomplete="off" onblur="closeBox()" placeholder="Search Now"/>
<input type="submit" value="Search" name="submit" style="height: auto; width: 60px; padding: 2px" />
<div id="suggestion" style="width: 548px">
</div>
</td>
</tr>
</table>
<br>
<hr>
<table>
<tr>
<td>
<?php
//count
$count_sql = "SELECT count(*) as c FROM searchengine WHERE title LIKE '%" . mysqli_real_escape_string($con,$query) . "%' OR keywords LIKE '%" . mysqli_real_escape_string($con,$query) . "%' OR link LIKE '%" . mysqli_real_escape_string($con,$query) . "%' ";
$search_count = mysqli_fetch_array(mysqli_query($con,$count_sql));
$number_of_result = $search_count['c'];
//SQL query
$stmt = "SELECT * FROM searchengine WHERE title LIKE '%" . mysqli_real_escape_string($con,$query) . "%' OR keywords LIKE '%" . mysqli_real_escape_string($con,$query) . "%' OR link LIKE '%" . mysqli_real_escape_string($con,$query) . "%' LIMIT " . $page_number . " , $results_per_page";
$result = mysqli_query($con,$stmt) or die(mysqli_error($con));
//$number_of_result = mysqli_num_rows($result);
$x++;
if($x==1)
if ($number_of_result < 1) {
echo "<b>No results found!</b>";
echo "<p>";
echo "Your search - <b>$query</b>" . " - did not match any documents. Please try different keywords.";
} elseif ($number_of_result > 1) {
echo "<b>$number_of_result results found!</b>";
echo "<p>";
//results found here and display them
$index = 1;
while (($row = \mysqli_fetch_assoc($result)) && ($index < 10)) {//10 results per page
$title = $row["title"];
$description = $row["description"];
$link = $row["link"];
echo "<div id='search-result'>";
echo "<div id='title'><a href='$link'>" . $title . "</a></div>";
//echo "<br />";
echo "<div id='link'><small>" . $link . "</small></div>";
//echo "<p>";
echo "<div id='description'><small>" . $description . "</small></div>";
echo "</div>";
echo "<br />";
$index++;
}
} elseif ($number_of_result == 1) {
echo "<b>$number_of_result result found!</b>";
echo "<p>";
//results found here and display them
$index = 1;
while (($row = \mysqli_fetch_assoc($result)) && ($index < 10)) {//10 results per page
$title = $row["title"];
$description = $row["description"];
$link = $row["link"];
echo "<div id='search-result'>";
echo "<div id='title'><a href='$link'>" . $title . "</a></div>";
//echo "<br />";
echo "<div id='link'><small>" . $link . "</small></div>";
echo "<br />";
echo "<div id='description'><small>" . $description . "</small></div>";
echo "</div>";
echo "<br />";
$index++;
}
}
?>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="page" value="0" />
<div id="page-number">
Select Page Number:
<?php
//ie if 35 results are therer then we require 4 pages that are 0 to max_page_number
//current page number is equal to page_number
$max_page_number = ceil($number_of_result / $results_per_page);
//echo $max_page_number;
echo "<ul>";
//both the condition are not the neccesary
if ($max_page_number > 2) { // if more than 2 pages
if ($page_number > 0 ) { //Previous
echo "<li id='search-page-number'>";
echo "Previous";
echo "</li>";
}
for($index = 0 ; $index < $max_page_number ; $index++)
{
echo "<li id='search-page-number'>";
echo "<a href=search.php?q=$query&page=".($index * $results_per_page).">";
echo ($index + 1) . "</a>";
echo "</li>";
}
if (($page_number + $results_per_page) < $number_of_result ) { //Next
echo "<li id='search-page-number'>";
echo "Next";
echo "</li>";
}
} elseif (($max_page_number == 2 ) ) {
echo "<li id='search-page-number'>";
echo "".($page_number == 0 ? "Next":"Previous" )."";
echo "</li>";
} elseif (($max_page_number == 1 ) ) {
echo "<li id='search-page-number'>";
echo "<a href=search.php?q=$query&page=0>1</a>";
echo "</li>";
}
echo "</ul>";
?>
</div>
</td>
</tr>
<tr>
<td align="center">
To insert your site in result fill in the form at here.
</td>
</tr>
</table>
</form>
</body>
</html>

not getting suitable output in fetching image and its description

I want to display images and their description(on hover) dynamically in a localhost application.
I am getting a vertical output:
but I want the images to be show horizontally (to a certain extent), like this:
I tried the following
PHP
<?php
$c = mysql_connect("localhost", "abc", "xyz");
mysql_select_db("root");
$q = "select * from product";
$qc = mysql_query($q);
$count = 0;
while ($ans = mysql_fetch_array($qc)) {
if ($count == 0 || $count == 1 || $count == 2) {
$title = $ans[1] . " " . $ans[2];
print '<div class="img-wrap">';
print "<img id='display_img' src='products/$ans[8]'width=300 height=200 title='$title'>";
print '<div class="img-overlay">';
print '<h4>' . $title . '</h4>';
print '<p>' . $ans[9] . '</p>';
print '</div>';
print '</div>';
}
$count++;
if ($count == 3) {
print "<br />";
$count = 0;
}
}
?>
CSS
.img-wrap {
height:200px;
position:relative;
width:300px;
margin:10px;
}
.img-overlay {
background-color:#000;
bottom:0;
color:#fff;
height:200px;
width:300px;
opacity:0;
position:absolute;
z-index:1000;
transition-duration:0.5s;
cursor:pointer;
}
.img-overlay h4, .img-overlay p {
padding:0 10px;
}
.img-wrap:hover .img-overlay {
opacity:0.75;
transition:opacity 0.5s;
}
b {
background-color:#aa490e;
color:#fff;
font-size:36px;
padding: 0 15px;
padding-left:65px;
padding-bottom:25px;
font-family:"Courier New", Courier, monospace;
}
Try changing .img-wrap as following:
.img-wrap
{
float:left;
clear:none;
height:200px;
position:relative;
width:300px;
margin:10px;
}
You can add display: inline-block to .img_wrap:
.img-wrap {
...
display: inline-block;
}
Or you can use float: left. But in this case make sure you clear: both after the last item.
http://jsfiddle.net/tRRVv/

Categories