madavies Posted February 27, 2009 Share Posted February 27, 2009 Hi, I am trying to display a set of fish relating to a particular species which has been taken from a mysql database, and I am having trouble getting it to layout correctly... This is what I would like to happen (ish): this is what happens: my code is here <?php # GRAB THE VARIABLES FROM THE URL if ($fish_species_finder = "") { $fish_finder_species = "Unknown Fish"; } else{ $fish_species_finder = $_GET['fish_finder']; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <META name="description" content="Glass Reef - Your Online Aquarium Book."> <META name="keywords" content="Reef, Marine Reef, Salt water aquarium, Fish FAQS, Fish Guide, Angelfish guide, invertebrate guide, marine aquarium help, how to make a reef tank, aquarium, fish, salt water, glass reef, T5 lighting"> <title>GlassReef.co.uk</title> <link href="file:///C|/Documents%20and%20Settings/Compaq_Owner/Desktop/glassreef/Graphics/CSS%20-%20Reef.css" rel="stylesheet" type="text/css"> <style type="text/css"></style> <script language="JavaScript" type="text/JavaScript"> <!-- <?php // set database server access variables: $host = "localhost"; $user = "root"; $pass = ""; $db = "glassreef"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM tblspecies_fish WHERE species_scientific_name = '$fish_species_finder'"; //$query = "SELECT * FROM tblspecies_fish"; THIS WAS THE ORIGINAL CODE // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_row($result)) { $title_graphic = $row[0]; $speciescommon = $row[1]; $scientificname = $row[2]; $overview = $row[3]; $fish_size = $row[4]; $tank_size = $row[5]; $diet = $row[6]; $temperature = $row[7]; $temperment = $row[8]; $care_level = $row[9]; $compatability = $row[10]; $unusual_needs = $row[11]; } echo "</table>"; } else { // no // print status message echo "No fish found!"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> </body> </html> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } //--> </script> <link href="Graphics/CSS - Reef.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style1 { color: #CC3300; font-weight: bold; } .style4 { font-size: 12px; font-weight: bold; } .style5 {font-size: 12px} body { background-color: #F4F4F4; } --> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> </head> <body> <div align="center"> <table width="787" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="CSS-Reef"> <!--DWLayoutTable--> <tr> <td height="154" colspan="9" valign="top"><script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','799','height','140','src','Reef','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','Reef' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="799" height="140"> <param name="movie" value="Reef.swf"> <param name="quality" value="high"> <embed src="Reef.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="799" height="140"></embed> </object> </noscript></td> </tr> <tr> <td colspan="4" rowspan="4" valign="top"> <?php ?> <img src="<?php echo $title_graphic; ?>" alt="<?php echo $speciescommon; ?>" width="269" height="43"></td> <td width="17" height="14"></td> <td width="264"></td> <td width="216"></td> <td width="18"></td> <td width="9"></td> </tr> <tr> <td height="14"></td> <td valign="top"><div align="left"><span class="style1">Overview</span></div></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="4"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29"></td> <td colspan="3" rowspan="4" valign="top"><div align="justify"> <?php echo $overview; ?> </div></td> <td></td> </tr> <tr> <td height="18" colspan="4" valign="top"><div align="center"><em><strong> <?php echo $scientificname; ?> </strong></em></div></td> <td></td> <td></td> </tr> <tr> <td width="234" height="25"> </td> <td width="7"></td> <td width="16"></td> <td width="18"></td> <td></td> <td></td> </tr> <tr> <td rowspan="5" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="230"> <!--DWLayoutTable--> <!--DWLayoutTable--> <!-- fwtable fwsrc="Lower.png" fwbase="Lower.jpg" fwstyle="Dreamweaver" fwdocid = "518691930" fwnested="0" --> <tr> <td height="41" colspan="4" valign="top"><img src="Graphics/Fish/FAQs-background/Lower_r1_c1.jpg" width="230" height="41"></td> <td width="3"> </td> <td width="2"></td> </tr> <tr> <td width="13" rowspan="2"><img name="Lower_r2_c1" src="Graphics/Fish/FAQs-background/Lower_r2_c1.jpg" width="13" height="338" border="0" id="Lower_r2_c1" alt="" /></td> <td width="98" height="329" valign="top"><p align="right" class="style4">Fish Size:<br> Diet<br> Tank Size: <br> <br> Temperature:<br> <br> Temperment :<br> <br> Care Level:<br> Compatability:<br> <br> Unusual Needs: <br> <br> </p> </td> <td width="93" valign="top"> <div align="center"><span class="style5"> <?php echo $fish_size; ?> <br> <?php echo $diet; ?><br> <?php echo $tank_size; ?><br> <br> <?php echo $temperature; ?> <br> <br> <?php echo $temperment; ?><br> <?php echo $care_level; ?><br> <?php echo $compatability; ?> <br> <br> <?php echo $unusual_needs; ?> <br> </span></div></td> <td width="26" rowspan="2"><img name="Lower_r2_c3" src="Graphics/Fish/FAQs-background/Lower_r2_c3.jpg" width="26" height="338" border="0" id="Lower_r2_c3" alt="" /></td> <td><img src="Graphics/Fish/FAQs-background/spacer.gif" alt="" name="undefined_2" width="1" height="329" border="0" /></td> <td></td> </tr> <tr> <td height="9" colspan="2"><img name="Lower_r3_c2" src="Graphics/Fish/FAQs-background/Lower_r3_c2.jpg" width="191" height="9" border="0" id="Lower_r3_c2" alt="" /></td> <td><img src="Graphics/Fish/FAQs-background/spacer.gif" alt="" name="undefined_2" width="1" height="9" border="0" /></td> <td></td> </tr> </table></td> <td height="94"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="16"></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="14"></td> <td></td> <td colspan="3" valign="top"><div align="left"><span class="style1"> Specific Breeds </span></div></td> <td></td> <?php $username="root"; $password=""; $database="glassreef"; $localhost ="localhost"; mysql_connect($localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM tblindividual_fish"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"fish_common_name"); $f2=mysql_result($result,$i,"fish_scientific_name"); $f3=mysql_result($result,$i,"species_scientific_name"); $f4=mysql_result($result,$i,"size"); $f5=mysql_result($result,$i,"origin"); $f6=mysql_result($result,$i,"temperment"); $f7=mysql_result($result,$i,"price"); $f8=mysql_result($result,$i,"photo"); ?> <td height="160"> </td> <td colspan="5" valign="centre"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="132" height="14"></td> <td width="92"></td> <td width="11"></td> <td width="296"></td> </tr> <td rowspan="3" valign="top"><img src=" <?php echo $f8;?>" alt="<?php echo $f1; ?>" <div align="center"></div></td> <td height="9"></td> <tr> <td height="118" valign="top"><p align="right"><strong>Name:</strong><br> <br> <strong>Size:</strong><br> <strong>Orgin:</strong><br> <strong>Unique Traits:</strong><br> <br> <br> <br> </p></td> <td> </td> <td valign="top"><p align="justify"><?php echo $f1; ?>  <i><?php echo $f2 ; ?> </i> <br> <br> <?php echo $f4; ?><br> <?php echo $f5; ?> <br> <?php echo $f6; ?><br> <br> <strong>Price: </strong><?php echo $f7; ?> </p></td> </tr> <tr> <td height="13"></td> <td></td> <td></td> </tr> <tr> <td height="2" colspan="4" valign="top"><hr></td> </tr> <tr> <td height="4"></td> <td></td> <td></td> <td></td> </table></td> <td> </td> <td></td> </tr> <tr> <td height="95"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td></td> </tr> <?php $i++; } ?> </table> </div> </body> </html> Anyone have any idea why the first row is organised correctly and the next one isnt? Link to comment https://forums.phpfreaks.com/topic/147168-layout-error-when-php-duplicates-for-another-row/ Share on other sites More sharing options...
rhodesa Posted February 27, 2009 Share Posted February 27, 2009 #1 DON'T POST IMAGE LINKS TO SITES WITH SPAM POPUPS #2 Use code tags when posting code, it's the button in the toolbar with the # sign on it Link to comment https://forums.phpfreaks.com/topic/147168-layout-error-when-php-duplicates-for-another-row/#findComment-772581 Share on other sites More sharing options...
madavies Posted February 27, 2009 Author Share Posted February 27, 2009 Ahh ok, does this forum allow you to edit posted subjects? Link to comment https://forums.phpfreaks.com/topic/147168-layout-error-when-php-duplicates-for-another-row/#findComment-772622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.