Jump to content

implementing php in to existing page should be simple


shortybookit

Recommended Posts

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();
    
?> 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 <?
$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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.