shortybookit Posted February 18, 2008 Share Posted February 18, 2008 database totally works and i love it but it only works on a test page when i put the database results on to an existing page it is screwed up on the top of the results page i want a little write up about the results i.e here are your results and then the results of the database search but it is not working like that currently the here are your results shows then the 1st record in the database then here are your results shows up again then the 2nd record in the database then the here are your results again and the 3rd record of the database if this is confusing maybe this will sum it up this is how it should be INTRO-and here are your results result 1 result 2 result 3 but this is how it is now INTRO-and here your results result 1 intro-and here r your results result 2 intro again result 3 why does the intro show up after every record in the database... here is the full code <?php require('template.php'); display_header( 'blah blah' ); mysql_connect("blah.secureserver.net", "user", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $query="SELECT * FROM contacts"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <? $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $writeup=mysql_result($result,$i,"writeup"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <style type="text/css"> <!-- .style1 {font-family: Georgia, "Times New Roman", Times, serif} .style4 {font-size: 16px} --> </style> <table width="475" height="733" border="0" align="center"> <tr> <td height="729" align="center" valign="top"><DIV class="white_title style1" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; BACKGROUND: #50b4cc; PADDING-BOTTOM: 4px; PADDING-TOP: 4px"> <h1><strong><a name="top"></a>companys</strong></h1> </DIV> <p class="style1"><img src="/images/image.jpg" alt="fd" width="286" height="120" hspace="8" vspace="6" align="left">here are your results .</span> <BR> <BR> <p class="content_title style1"> </p> <p class="content_title style1"> </p> <p class="content_title"> </p> <div>Content for New Div Tag Goes Here</div> <p class="content_title"> </p> <table width="380" align="center" cellpadding="0" cellspacing="0" class=""> <TR> <TD colSpan="2"><table width="470" cellpadding="0" cellspacing="0"> <TR> <TD class="style1"><DIV> <TABLE width="100%" border="0"> <TBODY> <TR> <TD width="56%" height="14" valign="top" bgcolor="#FFFFFF"><p align="center"><font face="Arial, Helvetica, sans-serif"><? echo "$company $last"; ?></font> <BR> </p> </TR> </TBODY> </TABLE> <DIV> <TABLE cellSpacing="5" cellPadding="0" width="100%" border="0"> <TBODY> <TR> <TD width="280" height="171" vAlign="top"><font face="Arial, Helvetica, sans-serif"><? echo "$writeup"; ?></font></TD> <TD vAlign="top" width="14"> </TD> <TD vAlign="top" width="157"><p> <font face="Arial, Helvetica, sans-serif"><? echo "$address"; ?></font> <BR> <font face="Arial, Helvetica, sans-serif"><? echo "$city $zip"; ?></font> <p><BR> <font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></p> <font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo "$email"; ?>">E-mail</a></font><br /> <font face="Arial, Helvetica, sans-serif"><a href="<? echo "$web"; ?>" target="_blank">Website</a></font> </p></TD> </TR> </TBODY> </TABLE><HR width="80%"> </table> <TR> <TD colSpan="2"><span class="style1"> <TR> </TR> </TBODY> </TABLE> </table> <? ++$i; } echo "</table>"; ?> <?php display_footer(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/ Share on other sites More sharing options...
priti Posted February 18, 2008 Share Posted February 18, 2008 Diffcult to track. Kindly define CSS for your page.It will also help you in the tracking. you can just go thru once in your code and find the looping zone and look out for this intro section are you printing it again and again. it couls be something like this kind of problem. Kindly look in to it. regards Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469330 Share on other sites More sharing options...
shortybookit Posted February 18, 2008 Author Share Posted February 18, 2008 i have css with in the template.php page and yes i am printing it over and over why i dont know the entire code is posted above though could you look through it? someone plz thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469334 Share on other sites More sharing options...
sasa Posted February 18, 2008 Share Posted February 18, 2008 part of code that you don't want to repeat move outside of your while loop Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469342 Share on other sites More sharing options...
shortybookit Posted February 18, 2008 Author Share Posted February 18, 2008 were is my loop? Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469347 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 <? $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $writeup=mysql_result($result,$i,"writeup"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> this is your loop Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469350 Share on other sites More sharing options...
shortybookit Posted February 18, 2008 Author Share Posted February 18, 2008 ok now the intro part is only showing once... good but now my page layout is completly outta wack is that something that this form can help with or no Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469356 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 try changing this: <? ++$i; } echo "</table>"; to this: <? ++$i; echo "</table>"; } Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469368 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 if that don't work please provide your revised code If your layout is wonky its the way your html is layed out, you may need to provide the resulting page. Quote Link to comment https://forums.phpfreaks.com/topic/91638-implementing-php-in-to-existing-page-should-be-simple/#findComment-469370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.