
February 23rd, 2003, 12:16 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Here is whole script
PHP Code:
<?php
session_start();
?>
<html>
<head>
<style type="text/css">
<!--
A:link{text-decoration:none}
A:visit{text-decoration:none}
A:active{text-decration:none}
A:hover{text-decration:none}
//-->
</style>
</style>
</head>
<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr align=center >
<td width=15% align="center"><img src="image/cat.jpg"></td><td style="font-Family:arial" valign=bottom width=100% align=left><span style="border-style:solid;background-color:Bisque;padding:3;width:100%;border-color:white;">
<a href="JP.php">Home</a> / <a href="change.php">Edit AND Change my profile</a> /
<a href="upload.php">Manage AND Upload my photo</a> / <a href="logout.php">Sign Out</a></span></td>
</tr>
</table>
<?php
if (!@mysql_connect('localhost', '****', '****')) {
die('Connection Failed. '.mysql_error()); // or whatever
}
if (!@mysql_select_db('******')) {
die('Database Selection Failed. '.mysql_error()); // or whatever
}
if($_GET['lname']==$lname){
mysql_query("UPDATE kk SET hit = hit + 1 where lname='$lname'")
or die(__LINE__.mysql_error());
$q = 'SELECT pic,fname,lname,gender,country,job, birth, CURRENT_DATE,(YEAR(CURRENT_DATE)-YEAR(birth))-(RIGHT(CURRENT_DATE,5)<RIGHT(birth,5)) AS age,language,education,mail,hit FROM kk order by id';
$num = mysql_query($q);
$numrows = mysql_num_rows($num); // now we have the total number of results.
$_SESSION["username"]=$username;
if(isset($_SESSION["username"])){
echo"<p style=\"border-style:solid;background-color:silver;border-color:white;color:white;width:100%;height:5%;font-Family:arial;text-align:center;\"><big><i><u>Now logn in</u></i></big> ------) You are ".$_SESSION["username"]." "."<font color=red>Current members are".$numrows."peple</font>"."</p>";
}
else{
print("<meta http-equiv=\"refresh\" content=\"1;url=login.html\">");
}
if ($num == 0) {
die('No Results.'); // do whatever you want here
}
$limit = 5; // num per page
// we need to know how many results pages to generate.
$pages = ceil($numrows / $limit); // as you said, ceil is a good idea :)
// now we figure out the current page
if (!isset($_GET['from']) || !is_numeric($_GET['from'])) {
$_GET['from'] = 0;
}
if ($_GET['from'] == 0) {
$current = 1;
} else {
$current = ($_GET['from'] / $limit) + 1;
}
// now we show the results
$q .= ' LIMIT '.$_GET['from'].', '.$limit;
$results = mysql_query($q);
$num2 = mysql_num_rows($results);
// include(some header file here); //perhaps
// build up some stats thingies
$first = ($current * $limit) - $limit + 1;
if ($num2 == $limit) {
$last = $first + $limit - 1;
} else {
$diff = $limit - $num2;
$last = $first + $limit - 1 - $diff;
}
echo '<table width="55%" align=center border=0 style="font-Family:arial;color:red;"><tr bgcolor=yellow><td align=center>Showing '.$numrows.' results on '.$pages.' pages</td><td align="center">Page '.$current.', Results '.$first.' to '.$last.'</td></tr></table>';
while ($r = mysql_fetch_array($results)) {
print("<table border=1 cellpadding=2 cellspacing=2 width=75% align=center>");
print("<tr>");
print("<td width=12%>");
print("<a href=\"upload.php\" ><img src=\"$r[pic]\" width=130 height=135 border=0></a>");
print("</td>");
print("<td valign=top>");
print("<table border=1 cellpadding=3 cellspacing=2 width=100% height=120 style=\"font-Family:arial;\">");
print("<tr >");
print("<td width=15%>");
print("Name:");
print("</td>");
print("<td width=35%>");
print($r["fname"]);
print("</td>");
print("<td width=15%>");
print("Gender:");
print("</td>");
print("<td width=35%>");
print($r["gender"]);
print("</td>");
print("</tr>");
print("<tr >");
print("<td width=15%>");
print("Nationality:");
print("</td>");
print("<td>");
print($r["country"]);
print("</td>");
print("<td width=15%>");
print("Occupation:");
print("</td>");
print("<td >");
print($r["job"]);
print("</td>");
print("</tr>");
print("<tr >");
print("<td width=15%>");
print("Spoken Language:");
print("</td>");
print("<td>");
print($r["language"]);
print("</td>");
print("<td width=15%>");
print("Education Level:");
print("</td>");
print("<td >");
print($r["education"]);
print("</td>");
print("</tr>");
print("<tr>");
print("<td colspan=3>");
print("<font color=green>E-mail<font color=red>---></font>");
print("<a href=\"mailto:$r[mail]\">$r[mail]</a>");
print("</td>");
print("<td>Age:");
print($r["age"]);
print("</td>");
print("</tr>");
print("<tr>");
print("<td colspan=3><font color=red size=2>To click to see the Profile:</font>");
print("<a href=\"JP.php?lname=$r[lname]\">$r[lname]</a>");
print("</td>");
print("<td>Hit:");
print($r["hit"]);
print("</td>");
print("</tr>");
print("</table>");
print("</td>");
print("</tr>");
print("<table>");
}
}
// now we want to show the links
echo"<br>";
echo"<span style=\"border-style:solid;background-color:silver;border-color:white;\"><font color=red>Page numbers</font>---------->";
for($i = 1; $i <= $pages; $i++) {
$start = ($i * $limit) - $limit;
if ($start == $_GET['from']) {
echo $i.' ';
} else {
echo '<a href="'.$_SERVER['PHP_SELF'].'?from='.$start.'">'.$i.'</a> ';
}
}
echo"</span>";
?>
|