Solved

Quering a database

Posted on 2001-06-16
5
203 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now