Solved

Quering a database

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
php image upload 3 27
php documentation 4 22
php connect() failed error 25 17
Web Reply Form - PHP with Upload 4 22
Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

13 Experts available now in Live!

Get 1:1 Help Now