Solved

Quering a database

Posted on 2001-06-16
5
208 Views
Last Modified: 2006-11-17
I am completly stuck i have my source code which select froma  database and the prints five records and the says next click next it show the next five however on the last page it all goes wrong





<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<table width="456" border="0" cellspacing="2" cellpadding="0" bgcolor="#9900FF" align="center">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#FFFFCC">
<tr>
<td>
<div align="center"><b><font face="Arial, Helvetica, sans-serif" size="2" color="#000000">
<?PHP echo $page_title_message_brds ?> - <?PHP echo $qry_town_data['t_name_upper'] ?>
</font></b></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p align="center"><font face="Arial, Helvetica, sans-serif" size="2">We Invite You to Leave Comments And Suggestions on Our Message Boards And Enter Our Chat Forum to Catch Up on The Latest Gossip.</font></p>
<table width="456" border="0" cellspacing="1" cellpadding="1" bordercolor="#FFFFFF" align="center">
<tr bgcolor="#0000CC">
<td width="19%">
<div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">&nbsp;<b>Date</b></font></div>
</td>
<td width="55%">
<div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">&nbsp;<b>Message Title </b></font></div>
</td>
<td width="26%">
<div align="left"> <font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">&nbsp;<b>Name</b></font></div>
</td>
</tr>
</table>
<align="left">











<?php
$hostname="";
$username="";
$password="";
$dbname="";
mysql_connect($hostname,$username,$password);
mysql_select_db($dbname);
$query="SELECT date_format(updated, '%d-%m-%Y') as updated,id,subject,author,author_email FROM messages where t_id = '$townid' and allow = 1 ORDER BY id DESC";
$result=mysql_query($query);

$intCount=mysql_num_rows($result);     //Total records
$intEach=5;                    //Records each page
$intPages=ceil($intCount/$intEach);     //Total Pages
if(!$intPage)
    $intPage=1;               //page No
   

mysql_data_seek($result,($intPage-1)*$intEach);
for($i=0;$i<5;$i++)
{
    if($row=mysql_fetch_row($result))


print "<table width=456 border=0 cellspacing=1 cellpadding=2 align=center>";
print "<tr bgcolor=#DFE1FF> ";
print "<td width=86>".$row[0]."</td>";
print "<td width=250>".$row[2]."</td>";
print "<td width=119>".$row[3]."</td>";
print "</tr>";
print "</table>";
}

if($intPage>1)
    print "<div align=center><font face=Arial, Helvetica, sans-serif color=#000000 size=2><a class=black_underline href=\" print "<div align=center><font face=Arial, Helvetica, sans-serif color=#000000 size=2><a class=black_underline href=\"".basename($PHP_SELF)."?intPage=".($intPage-1)."\">Previous Page</a> | ";.basename($PHP_SELF)."?intPage=".($intPage-1)."\">Previous Page</a> | ";
else
    print "<div align=center><font face=Arial, Helvetica, sans-serif color=#000000 size=2>";
if($intPage<$intPages)
    print "<a class=black_underline href=\"".basename($PHP_SELF)."?intPage=".($intPage+1)."\"> Next Page </a>";
else
    print "<font face=Arial, Helvetica, sans-serif color=#000000 size=2>";
print "<font face=Arial, Helvetica, sans-serif color=#000000 size=2>".$intPage." of &nbsp".$intPages;

?>

<p align="center"><font face="Arial, Helvetica, sans-serif" size="2"><a class=black_underline href="add_message.php">Post
your own message!</a></font></p>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp; </td>
</tr>
<tr>
<td bgcolor="#C0C0C0"><img src="http://www.<?PHP echo $domain ?>/images/structure/line.gif" width="100%" height="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="http://www.<?PHP echo $domain ?>/images/structure/block.gif" width="2" height="5"></td>
</tr>
<tr>
<td><?PHP include("/home/phpdev/public_html/content/footer/footer.php"); ?></td>
</tr>
</table>
0
Comment
Question by:Boroughman
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
us111 earned 110 total points
ID: 6198430
<td bgcolor="#C0C0C0"><img src="http://www. echo $domain ?>/images/structure/line.gif" width="100%" height="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="http://www. echo $domain ?>/images/structure/block.gif" width="2" height="5"></td>
</tr>
<tr>
<td><?PHP include("/home/phpdev/public_html/content/footer/footer.php"); ?></td>
</tr>
</table>

it looks there s a problem here!! you forgot 2 <?
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6419177
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange

P.S.  REGARDING POINTS, Guidelines and more:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6426479
If the answer given which you accepted is correct, I can change this, as apropos, from a C to an A grade.  The points to you are the same, but expert points are generated based upon grade assigned.

thanks,

Moondancer :)
Community Support Moderator @ Experts Exchange

0
 
LVL 8

Expert Comment

by:us111
ID: 6426966
I think the answer is correct :)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6646265
Grade corrected.
Moondancer :)
Community Support Moderator @ Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question