code:
<style>
.center {
float: left;
text-align: center;
}
.center h3 {
color: #000;
font-weight: 600;
}
.left {
font-size: 14px;
float: left;
width: 30%;
color: #000;
}
.right {
font-size: 14px;
float: right;
width: 70%;
color: #000;
}
#bot {
margin-bottom: 2em;
}
#left {
font-size: 14px;
float: left;
width: 42%;
color: #000;
}
#right {
font-size: 14px;
float: right;
width: 58%;
color: #000;
}
table, td, th {
border: 1px solid #000;
text-align: left;
font-size: 14px;
font-weight: inherit;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 15px;
}
#pp {
font-size:14px;
color:#000;
}
.table-responsive {
overflow-x: hidden!important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
padding:0px!important;
}
</style>
<div class="col-md-12">
<a href="javascript:void(0)" class="btn btn-success" style="float: right;" onclick='printDiv();'>Print Sheet</a>
</div>
<div id="print_wrapp">
<div class="col-md-12" id="bot">
<div class="col-md-2">
<img src="<?php echo base_url(); ?>uploads/images/Lingayas Vidyapeeth Logo.png" class="img-responsive" style="width: 110px;">
</div>
<div class="col-md-10">
<div class="center">
<h3>
Lingaya's Vidyapeeth, Fraidabad<br>
Award Sheet<br>
End Semester Examination<br>
(May-June, 2019)
</h3>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12" id="bot">
<div class="col-md-6">
<div class="left">
<p>Department: </p>
</div>
<div class="right">
<p><?php echo $award[0]['department_name']?></p>
</div>
<div class="left">
<p>Program/Course: </p>
</div>
<div class="right">
<p><?php echo $award[0]['classes']?></p>
</div>
<div class="left">
<p>Subject Name: </p>
</div>
<div class="right">
<p><?php echo $award[0]['subject']?></p>
</div>
<div class="left">
<p>Session: </p>
</div>
<div class="right">
<p><?php echo $award[0]['session']?></p>
</div>
</div>
<div class="col-md-6">
<div class="left">
<p>Semester: </p>
</div>
<div class="right">
<p><?php echo $award[0]['yearsOrSemester']?></p>
</div>
<div class="left">
<p>Subject Code: </p>
</div>
<div class="right">
<p><?php echo $award[0]['subject_code']?></p>
</div>
<div class="left">
<p>Maximum Marks: </p>
</div>
<div class="right">
<p></p>
</div>
</div>
</div>
<div class="col-md-12" id="bot">
<div class="col-md-12">
<div class="table-responsive">
<table id="example1" class="table table-striped table-bordered table-hover dataTable no-footer">
<thead>
<th>S.No.</th>
<th>Roll No.</th>
<th>Marks(In Figure)</th>
<th>Marks(in Words)</th>
</thead>
<tbody>
<?php
$i=1;
foreach($award as $row)
{
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row['roll']; ?></td>
<td></td>
<td></td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-12" id="bot">
<div class="col-md-6">
<div id="left">
<p>Total No. of Student Pass: </p>
</div>
<div id="right">
<p></p>
</div>
</div>
<div class="col-md-6">
<div id="left">
<p>Total No. of Student Fail: </p>
</div>
<div id="right">
<p></p>
</div>
</div>
</div>
</div>
</div>
<script>
function printDiv()
{
var divToPrint=document.getElementById('print_wrapp');
var newWin=window.open('','Print-Window');
newWin.document.open();
newWin.document.write('<html><link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/bootstrap/css/bootstrap.css" type="text/css" /><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){newWin.close();},10);
}
</script>
In this code I am simply run print content inside div <div id="print_wrapp"> by click function i.e printDiv and its working properly but the problem is that print preview css not showing div content properly and an image is mention below:
and my original page look like:
So, How can I fix this problem? Please help me.
Thank You
You can apply the style sheet too both print and screen using media='screen,print'
<link ../bootstrap.min.css' rel='stylesheet' media='screen,print'>
or
<link ../bootstrap.min.css' rel='stylesheet' media='all'>
When we want to apply some style when printing a page, we need to apply the styles using #media print. Then only the style will apply for windows print function.
Style.css
#media print
{
.center {
float: left;
text-align: center;
}
.center h3 {
color: #000;
font-weight: 600;
}
.left {
font-size: 14px;
float: left;
width: 30%;
color: #000;
}
.right {
font-size: 14px;
float: right;
width: 70%;
color: #000;
}
}
Then link the css file where you want to print the page with style.
<link rel="stylesheet" type="text/css" href="Style.css">
Call the Print Function on Button Click
<button onclick="printPage()" class="center">Print</button>
<script>
function printPage()
{
print();
}
</script>
I have a website which is using the CodeIgniter framework. In my one page I should get some data and list them. and I don't want to use the scrollbar on this page.
how can I get 3 data in cycle with jquery?
This code is getting just 1 data in cycle but I want to get 3 data in the cycle.
<ul class="list">
<?php foreach ($a_list as $hd) { ?>
<div id="content-1">
<a href="single.html">
<li>
<section class="list-left" style="border:0px solid red; width:30%; height:90px;">
<section class="list" style="border-bottom:1px solid red; width:100%; margin-top: 0; text-align: center">
<h6 class="title" >Hasta</h6>
</section>
<p class="adprice" style="color:black; text-align: center; font-size: -5;"><?= $hd->h_adi ?> <?= $hd->h_soyadi ?>
</section>
<section class="list-left"style="border:0px solid red; width:30%; height: 90px">
<section class="list" style="border-bottom:1px solid red; width:100%; margin-top: 0; text-align: center">
<h5 class="title" >Doktor</h5>
</section>
<p class="adprice" style="text-align: center">
<?= $hd->a_unvan ?>
<?= $hd->dr_adi ?>
<?= $hd->dr_sadi ?>
<br>
<p class=catpath style="text-align: center; margin-top: 0px !important; color:black">
<?=$hd->a_brans?>
Uzmanı
</p>
</p>
</section>
<section class="list-left" style="border:0px solid red; width:30%;height: 90px">
<section class="list" style="border-bottom:1px solid red; width:100%; margin-top: 0; text-align: center">
<h5 class="title" >Durum</h5>
</section>
<p class="adprice" style="color:blue;text-align: center"><?=$hd->h_durum?></p>
</section>
<div class="clearfix"></div>
</li>
</a>
</div>
<?php } ?>
<script src='<?=base_url()?>/assets/js/jquery.min.js'></script>
<script>
var divs = $('div[id^="content-"]').hide(),
i = 0;
(function cycle() {
divs.eq(i).fadeIn(400)
.delay(1000)
.fadeOut(400, cycle);
i = ++i % divs.length;
})();
</script>
<a href="single.html">
</a>
</ul>
zxcf
How do I hide my buttons "Inloggen" and "Registreren" when I am logged in? I have two seperate files; I have my index file with the menu etc and a inloggen file for the php and the form. If I am logged in I want the buttons to hide and replace it for a button with logout. How do I do that with my code?
Index:
<?php
require 'dbconnectie.php';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>PC4U</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="index.css" rel="stylesheet">
</head>
<body>
<div id="container1">
<header>
<div id="headerFotoDiv">
<img src="images/logo.jpg" height="100px" class="lihover" onclick="window.location='http://www.pc4u.hexodo.nl/'">
</div>
<div id="headerLogindiv">
<button class="btn btn-warning" onclick="window.location='?p=i'" style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">Inloggen</button>
<button class="btn btn-warning" onclick="window.location='?p=re'" style="width: 130px; height:30px; margin-left: 160px; margin-top: 15px; text-align: center;">Registreren</button>
</div>
</header>
<!-- Static navbar -->
<nav class="navbar navbar-default" style="width: 1000px; margin-bottom:0px;padding-bottom:0px;padding-top:0px;border:0px;border-bottom:1px solid #000;border-radius:0px; background-color:#FFFFFF;";>
<div class="container-fluid" style="padding:0px;">
<div id="navbar" class="navbar-collapse collapse" aria-expanded="true" style="height: 1px;padding:0px;">
<ul class="nav navbar-nav">
<li onclick="document.location.href='http://www.pc4u.hexodo.nl/'" class="lihover"><a>Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Computers
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>PC</li>
<li>Laptop</li>
</ul>
</li>
<li>Reparatie</li>
<li>Contact</li>
<li>Winkelwagen</li>
</ul>
</div>
</div>
</nav>
<!-- Vulling van de pagina -->
<div id="vulling">
<?php
if(isset($_GET['p'])) {
$pagina = $_GET['p'];
switch ($pagina) {
case "c":
include("contact.php");
break;
case "r":
include("reparatie.php");
break;
case "re":
include("registreren.php");
break;
case "i":
include("inloggen.php");
break;
case "w":
include("shoppingcart.php");
break;
case "ch":
include("computerhome.php");
break;
case "lp":
include("laptop.php");
break;
case "dp":
include("desktop.php");
break;
default:
include("home.php");
break;
}
}
else
{
include("home.php");
}
?>
</div>
</div>
</body>
</html>
Inloggen:
<?php
ob_start();
session_start();
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
//var_dump($_SESSION);
if(!isset($_POST['username']))
$_POST['username'] = '';
if(!isset($_POST['password']))
$_POST['password'] = '';
//if (isset($_SESSION['ingelogd'])&&$_SESSION ['ingelogd'] == true ) header("location: http://www.pc4u.hexodo.nl");
$dbhost = "localhost";
$dbuser = "*****";
$dbpass = "*****";
$dbname = "*****";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($conn->connect_error) die("Connection failed");
if (isset($_POST['submit'])) {
$uname = $_POST['username'];
$wwoord = $_POST['password'];
$query = 'SELECT * FROM Klanten WHERE klant_username = "' . $uname . '" && klant_wachtwoord = "' . $wwoord . '"';
$result = $conn->query($query);
if ($result->num_rows == 1) {
$_SESSION['ingelogd'] = true;
header("location: index.php");
} else {
$_SESSION['ingelogd'] = false;
$msg = "Inloggegevens incorrect.";
}
//$conn->close();
}
?>
<link href="contact.css" rel="stylesheet">
<style type="text/css">
input, td, tr {
padding-right: 20px;
}
</style>
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<label class="control-label col-sm-2" style="text-align: left; width: 120px; margin-left: 10px; margin-top: 10px;" for="username">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" name="username" style="width: 250px; margin-top: 10px;" required placeholder="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="password" style="text-align: left; width: 120px; margin-left: 10px; margin-top: 10px;">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password" style="width: 250px; margin-top: 10px;" required placeholder="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" style="margin-left: 120px; margin-bottom: 10px;" class="btn btn-default" name="submit">Inloggen</button>
</div>
</div>
</form>
Maybe try something like:
Just like in your login page check if the login session is set, if it is set show the logout button. If the login session is not set, display the 2 other buttons.
<div id="headerLogindiv">
<?php
if($_SESSION['ingelogd']){
?>
<button class="btn btn-warning" onclick="window.location=logout.php" style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">Uitloggen</button>
<?php
} else {
?>
<button class="btn btn-warning" onclick="window.location='?p=i'" style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">Inloggen</button>
<button class="btn btn-warning" onclick="window.location='?p=re'" style="width: 130px; height:30px; margin-left: 160px; margin-top: 15px; text-align: center;">Registreren</button>
}
</div>
Or you could use Jquery to check if the session has been set. First give the login / registratie button a different class then the logout button. For example: class="inloggen" for the login / registration. and class="logout" for the uitlog button. If it has been set $('.inlogen').hide() $('.uitloggen').show() visa versa
How do I hide my buttons "Inloggen" and "Registreren" when I am logged in?
You should just check if the session is set for the user or not. i.e., If the session isset
If the session is set, you should show logout button
Else if the session is not set then you should show logout and register button.
Here is what you should do
<?php
if(isset($_SESSION['ingelogd']))
{
?>
<button class="btn btn-warning" onclick="window.location=logout.php" style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">Uitloggen</button>
<?php
}
else
{
?>
<div id="headerLogindiv">
<button class="btn btn-warning" onclick="window.location='?p=i'" style="width: 130px; height:30px; margin-left: 160px; margin-top: 12px; text-align: center;">Inloggen</button>
<button class="btn btn-warning" onclick="window.location='?p=re'" style="width: 130px; height:30px; margin-left: 160px; margin-top: 15px; text-align: center;">Registreren</button>
</div>
<?php
}
?>
Suggestion :
Never have the db connection in all your files, you can just have a file named as config.php or something and you can include where it is required.
Tip for debugging :
To print all the sessions
<?php
session_start();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
?>
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 7 years ago.
Im trying to make a register system that will allow the user to make their own account, the script says that the information was sent to the database successfully, but in actual fact it's not. here is the code.
Index.php
<?php
include('login.php'); // Includes Login Script
if(isset($_SESSION['login_user'])){
header("location: home.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Network TV Login Page</title>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body style="background:center no-repeat fixed url('https://upload.wikimedia.org/wikipedia/commons/b/b5/Melbourne_by_night.jpg'); background-size: cover">
<div id="body"> <!-- Start body div -->
<div id="nav"> <!-- Start of nav-->
<nav class="navbar navbar-default navbar-fixed-top"> <!-- Start of nav class-->
<div class="container"> <!-- Start of nav container -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Network TV</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
</div><!--/.nav-collapse -->
</div> <!-- End of nav container -->
</nav> <!-- End of nav class-->
</div> <!-- End of nav -->
<center> <!-- center login/ registration forum -->
<div id="Login"> <!-- Start login/ registration div --->
</div> <!-- End login/ registration div-->
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-login">
<div class="panel-heading">
<div class="row">
<div class="col-xs-6">
<u>Login</u>
</div>
<div class="col-xs-6">
<u>Register</u>
</div>
</div>
<hr>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-12">
<form id="login-form" action="" method="post" role="form" style="display: block;">
<div class="form-group">
<input id="name" name="username" placeholder="Username" type="text" tabindex="1" class="form-control">
</div>
<div class="form-group">
<input id="password" name="password" placeholder="Password" type="password" tabindex="2" class="form-control">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input class="form-control btn btn-success" name="submit" type="submit" value="Log In" id="submit" tabindex="3" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-12">
<div class="text-center">
Forgot Password?
</div>
</div>
</div>
</div>
</form>
<form id="register-form" action="index.php" method="post" role="form" style="display: none;">
<div class="form-group">
<input type="text" name="newusername" id="newusername" tabindex="1" class="form-control validate-input" placeholder="Username" value="" autocomplete="off">
</div>
<div class="form-group">
<input type="email" name="newemail" id="newemail" tabindex="2" class="form-control validate-input" placeholder="Email Address" value="" autocomplete="off">
</div>
<div class="form-group">
<input type="password" name="newpassword1" id="password" tabindex="10" class="form-control" placeholder="Password" autocomplete="off">
</div>
<div class="form-group">
<input type="password" name="newpassword1" id="password" tabindex="10" class="form-control" placeholder="Password" autocomplete="off">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="register-submit" id="register-submit" tabindex="12" class="form-control btn btn-success" value="Register">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</center> <!-- Stop center -->
<div> <!-- End body div -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style>
body {
padding-top: 90px;
}
.panel-login {
border-color: #ccc;
-webkit-box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2);
box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2);
}
.panel-login>.panel-heading {
color: #00415d;
background-color: #fff;
border-color: #fff;
text-align:center;
}
.panel-login>.panel-heading a{
text-decoration: none;
color: #666;
font-weight: bold;
font-size: 15px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.panel-login>.panel-heading a.active{
color: #029f5b;
font-size: 18px;
}
.panel-login>.panel-heading hr{
margin-top: 10px;
margin-bottom: 0px;
clear: both;
border: 0;
height: 1px;
background-image: -webkit-linear-gradient(left,rgba(0, 0, 0, 0),rgba(0, 0, 0, 0.15),rgba(0, 0, 0, 0));
background-image: -moz-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0));
background-image: -ms-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0));
background-image: -o-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0));
}
.panel-login input[type="text"],.panel-login input[type="email"],.panel-login input[type="password"] {
height: 45px;
border: 1px solid #ddd;
font-size: 16px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.panel-login input:hover,
.panel-login input:focus {
outline:none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border-color: #ccc;
}
.btn-login {
background-color: #59B2E0;
outline: none;
color: #fff;
font-size: 14px;
height: auto;
font-weight: normal;
padding: 14px 0;
text-transform: uppercase;
border-color: #59B2E6;
}
.btn-login:hover,
.btn-login:focus {
color: #fff;
background-color: #53A3CD;
border-color: #53A3CD;
}
.forgot-password {
text-decoration: underline;
color: #888;
}
.forgot-password:hover,
.forgot-password:focus {
text-decoration: underline;
color: #666;
}
.btn-register {
background-color: #1CB94E;
outline: none;
color: #fff;
font-size: 14px;
height: auto;
font-weight: normal;
padding: 14px 0;
text-transform: uppercase;
border-color: #1CB94A;
}
.btn-register:hover,
.btn-register:focus {
color: #fff;
background-color: #1CA347;
border-color: #1CA347;
}
</style>
<script>
$(function() {
$('#login-form-link').click(function(e) {
$("#login-form").delay(100).fadeIn(100);
$("#register-form").fadeOut(100);
$('#register-form-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
$('#register-form-link').click(function(e) {
$("#register-form").delay(100).fadeIn(100);
$("#login-form").fadeOut(100);
$('#login-form-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
});
</script>
</body>
</html>
<?php
If($_POST){
mysql_connect("localhost","root","Oliver");
mysql_select_db("users");
if(isset($_POST['register-submit'])){
$user_name = $_POST['newusername'];
$password = $_POST['newpassword1'];
$email = $_POST['newemail'];
}
$passwordmd5 = md5($password);
$query = "insert into username (username,password,email) values ('$user_name','$passwordmd5','$email')";
$query = "DELETE FROM username WHERE username = ''";
mysql_connect("localhost","root","Oliver");
mysql_select_db("videos");
$query = "DELETE FROM videos WHERE name = ''";
if (mysql_query($query)){
echo 'registration successful';
exit;
}
}
?>
Login.php
<?php
session_start(); // Starting Session
$error=''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
}
else
{
// Define $username and $password
$username = $_POST['username'];
$password = md5($_POST['password']);
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysql_connect("localhost", "root", "Oliver");
// To protect MySQL injection for Security purpose
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
// Selecting Database
$db = mysql_select_db("users", $connection);
// SQL query to fetch information of registerd users and finds user match.
$query = mysql_query("select * from username where password='$password' AND username='$username'", $connection);
$rows = mysql_num_rows($query);
if(isset($_SESSION['login_user']))
session_destroy();
if ($rows == 1) {
$_SESSION['login_user']=$username; // Initializing Session
header("location: profile.php"); // Redirecting To Other Page
} else {
$error = "Username or Password is invalid";
}
mysql_close($connection); // Closing Connection
}
}
?>
I know I should upgrade the code to MySqli or PDO.
Sorry, this was getting hard to read in the comments... The below worked for me:
if(isset($_POST['register-submit'])){
$name = $_POST['newusername'];
$pass = md5($_POST['newpassword1']);
$email = $_POST['newemail'];
}
$query = "INSERT INTO `username` (`username`, `email`, `password`) VALUES ('$name', '$email', '$pass')";
I have the java and everything set up, but it's not paging. It shows the pagination page links but it doesn't limit it. Here is what I have:
<div class="pagination-holder clearfix" style="float: right;">
<div id="compact-pagination" ></div></div>
</div>
<div class="pagination-holder clearfix" style="float: right;">
<div id="compact-pagination" style="float: right;"></div></div>
<div id="compact-pagination" style="float: right;"></div>
<SCRIPT type="text/javascript">
$(function() {
$('#compact-pagination').pagination({
edges: 2,
currentPage: 1,
hrefText: "#page-",
prevText: "Prev",
nextText: "Next",
items: <? echo $count; ?>,
itemsOnPage: 2,
cssStyle: 'compact-theme'
});
});
</SCRIPT>
Then my php here.
So why won't it limit?
Link: http://flaviusmatis.github.com/simplePagination.js/
Php:
<?php $sql = "SELECT
*
FROM
users
ORDER BY user_id";
$result = mysql_query($sql);
if(!$result)
{
echo 'The category could not be displayed, please try again later.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{header('/');
echo 'This category does not exist.';
}
else
{
//display category data
while($row = mysql_fetch_assoc($result))
{
?>
<ul class="memberlist">
<li> <div id="memberlist" style="float: left; width: 300px; margin-left: 11px; margin-top: 10px; margin-bottom: 10px; border: 1px solid #CCC; border-radius:7px; background-color:#666;padding:5px 5px 5px 5px;">
<div id="memberlist_top">
<div id="memberlist_avatar">
<img src="<?php echo $row['avatar'] ?>" style="border: 1px solid #CBCBCB; padding: 3px; width: 100px; height: 100px;" />
</div>
<div id="memberlist_top_right">
<p id="memberlist_username"><?php echo $row['user_name'] ?></p>
<p style="text-align: center;"><img src="<?php echo$row['site_rank_image']?>"</p>
<p style="text-align: center;" id="ml_rep"> Reputation: 0 </p>
<p id="ml_posts">Post count: <?php echo $row['post'] ?></p>
</div>
<div class="clearfix" style="height: 5px;"> </div>
</div>
<div id="memberlist_bottom">
<p id="ml_bottom_p"><img src="template/images/layout/icon.png" style="vertical-align: middle" /> Date Registered: <span id="ml_bottom_span"><?php echo date(" F j, Y, g:i A", strtotime($row['user_date']))?> </span></p>
<p id="ml_bottom_p"><img src="template/images/layout/icon.png" style="vertical-align: middle" /> Last online: <span id="ml_bottom_span"><?php echo date(" F j, Y, g:i A", strtotime($row['dt']))?> </span></p>
<p id="ml_bottom_p" style="width: 284px; height: 30px; overflow-x: hidden; cursor: pointer;" title="Coming Soon"><img src="template/images/layout/icon.png" style="vertical-align: middle;" /> Last Activity: <span id="ml_bottom_span" style="text-decoration: underline;">Coming Soon</span></p>
<p id="ml_bottom_p"><img src="template/images/layout/icon.png" style="vertical-align: middle" /> Is online now: <span id="ml_bottom_span"> <? if($row
['online'] == 1) { // checks to see if the user allows their email to be shown, where '1' means they allow it to be shown
echo'Yes';
} else {
echo'No'; // if they allow it, it displays their email
} ?> </span></p>
</div>
</div> </li>
</ul>
<? }}}?>
How To Use
Step 1: together with JQuery, include jquery.simplePagination.js in your page:
<script type="text/javascript" src="path_to/jquery.js"></script>