php help?

Soldato
Joined
11 Apr 2003
Posts
4,208
Location
Notts
Hi all, I have been running my site with the use of tables, and im currently trying to get rid of them, I have the basic template working now, however I am having a problem calling the information from my database to display on my menu, I use to use:

Origional: http://jcb33.co.uk/index.php

New: http://jcb33.co.uk/host/Website Final/

Code:
    <table width="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="23" class="quickHeading">Latest Updates </td>
      </tr>
      <?php

			  	     // retrieve all the rows from the database in jcb_quickMenu table.
			  	     $query2 = "SELECT * FROM `jcb_quickMenu` WHERE sectionID = 'Latest Updates' ORDER BY `menuID`";
			  	     $results2 = mysql_query( $query2 );

			  	     // print out the results
			  	     if( $results2 )
			  	     {
			  	        while( $contact2 = mysql_fetch_object( $results2 ) )
			  	        {
			  	           // print out the info

			  	           $menuUrl = $contact2 -> menuUrl;
			  	           $menuTitle = $contact2 -> menuTitle;

			  	           echo("<tr>");
						   echo("   <td height=\"18\"><a href=\"$menuUrl\" class=\"quickLinks\">$menuTitle</a></td>");
                           echo("</tr>");

			  	        }
			  	     }
			  	     else
			  	     {
			  	        die("Mysql problem : " . mysql_error() );
			  	     }
                 ?>
      <tr>
        <td height="10"></td>
      </tr>
      <tr>
        <td height="23" class="quickHeading">Quick Links</td>
      </tr>
Etc, however I cannot get the php to call the information without inserting it into a table, help?
 
PHP:
echo "<td height=\"18\"><a href=\"" . $menuUrl . "\" class=\"" . quickLinks . \">" . $menuTitle . "<a/></td>";

Instead of your echo ("td etc

Think it will work or im talking **** :)
 
Thanks, had to modify it a bit as it was breaking my page but... Managed to get it with:

Code:
			  	           echo("<span class=\"quickHeading\"> Quick Links\n");
					   echo ("<a href=\"$menuUrl\" target=\"_self\" class=\"quickHeading\">$menuTitle</a></span>");

Just have to repeat the code for each different one :/
 
surely just put that into a while lopp, while there is an item output 1 for each ?
So if you have 5 items it loops 1-5 then stops as theres no more ? :)
 
Well:
Code:
div id="sidenavbar">
			<script type="text/javascript">
          			disShow(document)
      			</script>
			<?php
			  	     // retrieve all the rows from the database in jcb_quickMenu table.
			  	     $query2 = "SELECT * FROM `jcb_quickMenu` WHERE sectionID = 'Latest Updates' ORDER BY `menuID`";
			  	     $results2 = mysql_query( $query2 );

			  	     // print out the results
			  	     if( $results2 )
			  	     {
					echo("<span class=\"quickHeading\"> Latest Updates<br />");
			  	        while( $contact2 = mysql_fetch_object( $results2 ) )
			  	        {
			  	           // print out the info

			  	           $menuUrl = $contact2 -> menuUrl;
			  	           $menuTitle = $contact2 -> menuTitle;

					   echo ("<a href=\"$menuUrl\" target=\"_self\" class=\"quickHeading\">$menuTitle</a><br /></span>");
					}					
			  	     }
			  	     else
			  	     {
			  	        die("Mysql problem : " . mysql_error() );
			  	     }
                	 ?>
      			<?php
			  	     // retrieve all the rows from the database in jcb_quickMenu table.
			  	     $query3 = "SELECT * FROM `jcb_quickMenu` WHERE sectionID = 'Quick Links' ORDER BY `menuID`";
			  	     $results3 = mysql_query( $query3 );

			  	     // print out the results
			  	     if( $results3 )
			  	     {
					echo("<span class=\"quickHeading\"> Quick Links<br />");
			  	        while( $contact3 = mysql_fetch_object( $results3 ) )
			  	        {
			  	           // print out the info

			  	           $menuUrl = $contact3 -> menuUrl;
			  	           $menuTitle = $contact3 -> menuTitle;

			  	           echo ("<a href=\"$menuUrl\" target=\"_self\" class=\"quickHeading\">$menuTitle</a><br /></span>");

			  	        }
			  	     }
			  	     else
			  	     {
			  	        die("Mysql problem : " . mysql_error() );
			  	     }
                  	?>
			<?php

			  	     // retrieve all the rows from the database in jcb_quickMenu table.
			  	     $query4 = "SELECT * FROM `jcb_quickMenu` WHERE sectionID = 'Favorite Links' ORDER BY `menuID`";
			  	     $results4 = mysql_query( $query4 );

			  	     // print out the results
			  	     if( $results4 )
			  	     {
					echo("<span class=\"quickHeading\"> Favorite Links<br />");
			  	        while( $contact4 = mysql_fetch_object( $results4 ) )
			  	        {
			  	           // print out the info

			  	           $menuUrl = $contact4 -> menuUrl;
			  	           $menuTitle = $contact4 -> menuTitle;

			  	           echo ("<a href=\"$menuUrl\" target=\"_self\" class=\"quickHeading\">$menuTitle</a><br /></span>");

			  	        }
			  	     }
			  	     else
			  	     {
			  	        die("Mysql Problem: " . mysql_error() );
			  	     }
                 	?>
      			<?php

			  	     // retrieve all the rows from the database in jcb_quickMenu table.
			  	     $query5 = "SELECT * FROM `jcb_quickMenu` WHERE sectionID = 'Usefull Links' ORDER BY `menuID`";
			  	     $results5 = mysql_query( $query5 );

			  	     // print out the results
			  	     if( $results5 )
			  	     {
					echo("<span class=\"quickHeading\"> Usefull Links<br />");
			  	        while( $contact5 = mysql_fetch_object( $results5 ) )
			  	        {
			  	           // print out the info
			  	           $menuUrl = $contact5 -> menuUrl;
			  	           $menuTitle = $contact5 -> menuTitle;

			  	           echo ("<a href=\"$menuUrl\" target=\"_self\" class=\"quickHeading\">$menuTitle</a><br /></span>");
			  	        }
			  	     }
			  	     else
			  	     {
			  	        die("Mysql problem : " . mysql_error() );
			  	     }
                	 ?>
			<br />
      			<!-- Valid HTML Banner  -->
      			<div align="center"><a href="http://validator.w3.org/check?uri=referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" width="88" height="31" border="0" class="quickBg" /></a></div>
      			<!-- Valid CSS Banner  -->
      			<div align="center"><a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /> </a></div>
      			<!-- Firefox Banner  -->
      			<a href="http://www.spreadfirefox.com/?q=affiliates&amp;id=0&amp;t=76"> <img border="0" alt="Get Firefox!" title="Get Firefox!" src="http://sfx-images.mozilla.org/affiliates/Buttons/120x60/take.gif"/> </a>
				</div>
 
Back
Top Bottom