van21691
05-26-2009, 08:15 AM
I just don't get it, I put id as my primary, I have my code to DESC. It still not doing its job.
<?php
// Make a MySQL Connection
mysql_connect("localhost", "xxxxx", "1234") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());
$result = mysql_query("SELECT * FROM table ORDER BY id DESC " )
or die(mysql_error());
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
//view the news article!
if(isset($_GET['name']) && $_GET['fsid'] == "view")
{
$fsid = $_GET['fsid'];
$sql = mysql_query("SELECT * FROM kc WHERE fsid = '$fsid'");
while($r = mysql_fetch_array($sql))
{
$name = $r['name'];
$fsid = $r['fsid'];
$id = $r['id'];
$email = $r['email'];
$image = $r['image'];
$quote = $r['quote'];
echo " <br>";
}
}else{
//view all the news articles in rows
$sql = mysql_query("SELECT * FROM kc LIMIT ".$limits.",$max") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM kc"),0);
$totalpages = ceil($totalres / $max);
//the table
echo "<br>";
while($r = mysql_fetch_array($sql))
{
$id = $r['id'];
$fsid = $r['fsid'];
$name = $r['name'];
$email = $r['email'];
$time = $r['time'];
$image = $r['image'];
$quote = $r['quote'];
echo "<table width=360 height=190 border=1><tr>";
echo "<th width=145 rowspan=6 scope=row><img src=";
echo $r['image'];
echo " width=100 height=120></th><td colspan=2><div align=center>";
echo " -";
echo $r['id'];
echo "-";
echo "</div></td></tr><tr><td width=83>";
echo "<div align=right>NAME</div></td><td width=136><div align=left>";
echo $r['name'];
echo "</div></td></tr> <tr>";
echo "<td><div align=right>Email Add</div></td><td><div align=left>";
echo $r['email'];
echo "</div></td></tr><tr>";
echo "<td><div align=right>Quote</div></td> <td><div align=left>";
echo $r['quote'];
echo "</div></td></tr> <tr>";
echo "<td colspan=2><div align=center><a href=http://profiles.friendster.com/";
echo $r['fsid'];
echo ">View my profile</a></div></td></tr></table>";
}
}
//close up the table
echo "<br>";
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a href='index.php?p=$i'>$i</a> | ";
}
?>
This is the form
<FORM action="/chat/insert.php" method="post">
<font color=black>Name:</font> </font><input type="text" name="name" onClick="notEmpty(document.getElementById('req1'), 'Please Enter a Value')"><br>
<font color=black>Email:</font> <input type="text" name="email" onClick="notEmpty(document.getElementById('req2'), 'Please Enter a Value')"><br>
<font color=black>Image:</font><input type="text" name="image" value="http://thiz.ismywebsite.com/chat/nophoto.jpg"> <font color=black>- Include <b>HTTP://</b></b><br>
<font color=black>Friendster ID:</font><input type="text" name="fsid" onClick="notEmpty(document.getElementById('req3'), 'Please Enter a Value')"> - <br>
<font color=black>Quote:</font> <input type="text" name="quote" onClick="notEmpty(document.getElementById('req4'), 'Please Enter a Value')">
<INPUT type="submit" value="submit">
Can someone check if the code is right, I'm still learing php and mysql
<?php
// Make a MySQL Connection
mysql_connect("localhost", "xxxxx", "1234") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());
$result = mysql_query("SELECT * FROM table ORDER BY id DESC " )
or die(mysql_error());
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
//view the news article!
if(isset($_GET['name']) && $_GET['fsid'] == "view")
{
$fsid = $_GET['fsid'];
$sql = mysql_query("SELECT * FROM kc WHERE fsid = '$fsid'");
while($r = mysql_fetch_array($sql))
{
$name = $r['name'];
$fsid = $r['fsid'];
$id = $r['id'];
$email = $r['email'];
$image = $r['image'];
$quote = $r['quote'];
echo " <br>";
}
}else{
//view all the news articles in rows
$sql = mysql_query("SELECT * FROM kc LIMIT ".$limits.",$max") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM kc"),0);
$totalpages = ceil($totalres / $max);
//the table
echo "<br>";
while($r = mysql_fetch_array($sql))
{
$id = $r['id'];
$fsid = $r['fsid'];
$name = $r['name'];
$email = $r['email'];
$time = $r['time'];
$image = $r['image'];
$quote = $r['quote'];
echo "<table width=360 height=190 border=1><tr>";
echo "<th width=145 rowspan=6 scope=row><img src=";
echo $r['image'];
echo " width=100 height=120></th><td colspan=2><div align=center>";
echo " -";
echo $r['id'];
echo "-";
echo "</div></td></tr><tr><td width=83>";
echo "<div align=right>NAME</div></td><td width=136><div align=left>";
echo $r['name'];
echo "</div></td></tr> <tr>";
echo "<td><div align=right>Email Add</div></td><td><div align=left>";
echo $r['email'];
echo "</div></td></tr><tr>";
echo "<td><div align=right>Quote</div></td> <td><div align=left>";
echo $r['quote'];
echo "</div></td></tr> <tr>";
echo "<td colspan=2><div align=center><a href=http://profiles.friendster.com/";
echo $r['fsid'];
echo ">View my profile</a></div></td></tr></table>";
}
}
//close up the table
echo "<br>";
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a href='index.php?p=$i'>$i</a> | ";
}
?>
This is the form
<FORM action="/chat/insert.php" method="post">
<font color=black>Name:</font> </font><input type="text" name="name" onClick="notEmpty(document.getElementById('req1'), 'Please Enter a Value')"><br>
<font color=black>Email:</font> <input type="text" name="email" onClick="notEmpty(document.getElementById('req2'), 'Please Enter a Value')"><br>
<font color=black>Image:</font><input type="text" name="image" value="http://thiz.ismywebsite.com/chat/nophoto.jpg"> <font color=black>- Include <b>HTTP://</b></b><br>
<font color=black>Friendster ID:</font><input type="text" name="fsid" onClick="notEmpty(document.getElementById('req3'), 'Please Enter a Value')"> - <br>
<font color=black>Quote:</font> <input type="text" name="quote" onClick="notEmpty(document.getElementById('req4'), 'Please Enter a Value')">
<INPUT type="submit" value="submit">
Can someone check if the code is right, I'm still learing php and mysql