Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    6

    Unanswered: database outputting my entire page for each record, why?

    First off, thanks for helping. You can easily see my problem here:
    http://www.racksandfins.com/guides.p...ishing%20Guide

    How can I get it to just output the records from the table and not reproduce the whole page for EACH record? My entire php code is pasted below. I think I am putting something in the wrong place. Any help would be awesome.
    Thanks a TON,
    nat

    Code:
    <?
    include("admin/customers/dbcustomers.inc.php");
    mysql_connect(mysql,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM customers WHERE cust_subtype='$cust_subtype'";
    $result=mysql_query($query);
    $num=mysql_numrows($result); 
    mysql_close();
    $cust_type="contacts";
    
    
    ?>
    
    
    <?
    $i=0;
    while ($i < $num) {
    $cust_type=mysql_result($result,$i,"cust_type");
    $type_name=mysql_result($result,$i,"type_name");
    $cust_subtype=mysql_result($result,$i,"cust_subtype");
    $company=mysql_result($result,$i,"company");
    $contact=mysql_result($result,$i,"contact");
    $address=mysql_result($result,$i,"address");
    $city=mysql_result($result,$i,"city"); 
    $state_res=mysql_result($result,$i,"state_res"); 
    $zip=mysql_result($result,$i,"zip"); 
    $region=mysql_result($result,$i,"region"); 
    $area=mysql_result($result,$i,"area"); 
    $bus_phone=mysql_result($result,$i,"bus_phone"); 
    $fax=mysql_result($result,$i,"fax"); 
    $cell=mysql_result($result,$i,"cell");
    $email=mysql_result($result,$i,"email"); 
    $website=mysql_result($result,$i,"website"); 
    $comments=mysql_result($result,$i,"comments"); 
    $submitted_by=mysql_result($result,$i,"submitted_by");  
    $id=mysql_result($result,$i,"id");
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="javascript" src="ts_files/scroll.js"></script>
    
    <head>
    <title>Hunting and Fishing Super Site</title>
    --some js removed--
    </head>
    
    <body leftmargin="2" topmargin="2" marginwidth="2" marginheight="2">
    <script language="JavaScript1.2">mmLoadMenus();</script>
    <table width="700" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCC99">
      <tr>
        <td height="549" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="126" height="507" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="126">
                <tr>
                  --html removed--
                                  <td width="216"><img src="navslices/dummyad.gif" width="234" height="60" /></td>
                  <td width="44">&nbsp;</td>
                </tr>
                <tr>
                  <td height="23">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr bgcolor="#333333">
                  <td height="20">&nbsp;</td>
                  <td colspan="3"><img src="navslices/topnavAboutUs.gif" width="78" height="20" /><a href="mailto:info@racksandfins.com"><img src="navslices/topnavContactUs.gif" width="78" height="20" border="0" /></a><img src="navslices/topnavAdvertise.gif" width="78" height="20" /><a href="javascript:;" onMouseOver="MM_showMenu(window.mm_menu_0724011821_0,0,20,null,'image1')" onMouseOut="MM_startTimeout();"><img src="navslices/topnavCommunity.gif" name="image1" width="78" height="20" border="0" id="image1" /></a></td>
                  <td><div align="right"><img src="navslices/topNavRoundRt.gif" width="38" height="20" /></div>
                  </td>
                </tr>
                <tr bgcolor="#CCCC99">
                  <td height="20" colspan="5"> <br />
                      <table width="95%" height="101" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr> 
                          <td width="1" height="19">&nbsp;</td>
                        </tr>
                        <tr> 
                          <td height="42"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="2" class="FORMlive">
                              <tr> 
                                <td colspan="2"><strong><? echo "$cust_subtype"; ?></strong></td>
                                <td colspan="2" nowrap>&nbsp;</td>
                                <td colspan="2">&nbsp;</td>
                              </tr>
                              <tr> 
                                <td width="125"></td>
                                <td width="149"></td>
                                <td width="67"></td>
                                <td width="144"></td>
                                <td width="24"></td>
                                <td width="147"></td>
                              </tr>
                              <tr> 
                                <td height="20" valign="middle"> <div align="right"><strong>Business/Company</strong></div></td>
                                <td><? echo "$company"; ?></td>
                                <td><div align="right"><strong>Contact</strong></div></td>
                                <td colspan="3"><? echo "$contact"; ?></td>
                              </tr>
                              <tr> 
                                <td height="20" valign="middle"> <div align="right"><strong>Address</strong></div></td>
                                <td><? echo "$address"; ?></td>
                                <td><div align="right"><strong>City/State</strong></div></td>
                                <td valign="middle"><? echo "$city"; ?> <? echo "$state_res"; ?></td>
                                <td><div align="right"><strong>Zip</strong></div></td>
                                <td><? echo "$zip"; ?></td>
                              </tr>
                              <tr> 
                                <td valign="middle"> <div align="right"></div></td>
                                <td>&nbsp;</td>
                                <td><div align="right"></div></td>
                                <td>&nbsp;</td>
                                <td><div align="right"></div></td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr> 
                                <td height="20" valign="middle"> <div align="right"><strong>Region</strong></div></td>
                                <td><? echo "$region"; ?></td>
                                <td><div align="right"><strong>Area</strong></div></td>
                                <td><? echo "$area"; ?></td>
                                <td><div align="right"></div></td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr> 
                                <td height="15" valign="middle"> <div align="right"></div></td>
                                <td>&nbsp;</td>
                                <td><div align="right"></div></td>
                                <td>&nbsp;</td>
                                <td><div align="right"></div></td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr> 
                                <td height="20" valign="middle"> <div align="right"><strong>Business 
                                    Phone</strong></div></td>
                                <td><? echo "$bus_phone"; ?></td>
                                <td><div align="right"><strong>Fax</strong></div></td>
                                <td><? echo "$fax"; ?></td>
                                <td><div align="right"><strong>Cell</strong></div></td>
                                <td><? echo "$cell"; ?></td>
                              </tr>
                              <tr> 
                                <td height="20" valign="middle"> <div align="right"><strong>Email</strong></div></td>
                                <td><? echo "$email"; ?></td>
                                <td><div align="right"><strong>Website</strong></div></td>
                                <td colspan="3"><? echo "$website"; ?></td>
                              </tr>
                              <br>
                              <hr align="center" width="40%">
                              <br>
    
                            </table></td>
                        </tr>
                        <tr> 
                          <td height="19">&nbsp;</td>
                        </tr>
                        <tr> 
                          <td height="19">&nbsp;</td>
                        </tr>
                      </table>
                      <div align="center"></div>
                      <table height="29" border="0" cellpadding="0" cellspacing="0">
                        <tr> 
                          <td width="1" height="19">&nbsp;</td>
                        </tr>
                        <tr> 
                          <td height="10">&nbsp;</td>
                        </tr>
                      </table>
                  </td>
                </tr>
              </table>
            </td>
            <td valign="middle" bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="rightAds">
                <tr><img src="images/advertisement.gif" /></tr>
                <tr>
                  <td><a href="http://www.ybarranch.com/" target="_blank"><img src="navslices/spacer.gif" width="120" height="240" border="0" align="middle" /></a></td>
                </tr>
                <tr> </tr>
              </table>
            </td>
          </tr>
        </table></td>
      </tr>
    </table>
    
    <table width="700" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="center">Please contact us at <a href="mailto:info@racksandfins.com">info@racksandfins.com</a></div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>
                              <?
    ++$i;
    } 
    
    
    ?>

  2. #2
    Join Date
    Jun 2003
    Posts
    20
    while means "do this over and over again" whatever is inside the while gets done over and over.

    just put the starting html for the page above the while, the ending html below the while, and the db info within the while.
    Last edited by jbroder; 09-08-03 at 20:58.

  3. #3
    Join Date
    Aug 2003
    Posts
    6
    Great explaination, thanks! I Moved the } and all is good now.
    Thanks a lot,
    Nat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •