will_1990 Posted December 11, 2008 Share Posted December 11, 2008 I am trying to echo tables and i am doing this in a very basic way eg "echo '<table';" so i have slight error in my code that outputs the table but my variable is put out as text rather than the information its meant to collect! Im sure this is probably just a matter of having the right quotes in the right place. Here is a small segment of my code for anyone interested to look at.. <?php while($row = mysql_fetch_array($result)) { echo '<table border="1">'; echo '<tr>'; echo '<td>'; echo '"$row"["flight_num"]'; echo '</td>'; echo '</tr>'; echo '</table>'; ?> many thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/ Share on other sites More sharing options...
Twister1004 Posted December 11, 2008 Share Posted December 11, 2008 I have to also play around with the quotes for this to happen. But think of it this way. " " - double quotes should always start a Echo.then anywhere in the echo with double quotes you can use single quotes. while($row = mysql_fetch_array($result)){ echo '<table border="1">'; echo '<tr>'; echo '<td>'; echo "'$row['flight_num']'"; //changed this row. Look at it. echo '</td>'; echo '</tr>'; echo '</table>'; //Also you forgot the ending } sign. } Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712444 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 I have to also play around with the quotes for this to happen. But think of it this way. " " - double quotes should always start a Echo.then anywhere in the echo with double quotes you can use single quotes. while($row = mysql_fetch_array($result)) { echo '<table border="1">'; echo '<tr>'; echo '<td>'; echo "'$row['flight_num']'"; //changed this row. Look at it. echo '</td>'; echo '</tr>'; echo '</table>'; //Also you forgot the ending } sign. } ?> Sorry that code edit failed, i got not output to the users (aka just a blank page rather than ""$row"["flight_num"]"" in a table. below i will post a larger chunk of code incase its important, also the while loop continues further down the page.. ill show you. <?php if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div class="inner" > <?php while($row = mysql_fetch_array($result)) { echo '<table border="1">'; echo '<tr>'; echo '<td>'; echo '"$row"["flight_num"]'; echo '</td>'; echo '</tr>'; echo '</table>'; ?> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> </body> </html> <?php } }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> many thanks Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712450 Share on other sites More sharing options...
redarrow Posted December 11, 2008 Share Posted December 11, 2008 <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1'> <tr> <td> ".$row['flight_num']." </td> </tr> </table> <br><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712452 Share on other sites More sharing options...
Twister1004 Posted December 11, 2008 Share Posted December 11, 2008 Ill look through it, and post random comment signs. Honestly, there wasnt much to fix. the only thing i fixed was the while loop. <?php if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div class="inner" > <table border="1"> <?php while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>"; echo ".$row['flight_num']."; echo "</td>"; echo "</tr>"; } ?> </table> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712459 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1'> <tr> <td> ".$row['flight_num']." </td> </tr> </table> <br><br>"; } ?> worked a treat mate thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712462 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 I am trying to add in another row with a heading column 'Flight Number'. I tried adding this to the php and tired a number of ways but its not displaying the table. Please find below my attempt of adding this to the code. Any help would be much appreciated. <?php while($row = mysql_fetch_array($result)){ echo " <table border='1'> <tr> <td>"Flight Number"</td></tr> <tr> <td> ".$row['flight_num']." </td> </tr> </table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712476 Share on other sites More sharing options...
waterssaz Posted December 11, 2008 Share Posted December 11, 2008 no offence or anything but its a lot easier to raed if you use code tags when posting snippets of code. From the above you appear to have no closing curly brace for your while lopp ;-) Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712486 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 no offence or anything but its a lot easier to raed if you use code tags when posting snippets of code. From the above you appear to have no closing curly brace for your while lopp ;-) I know sorry, i will try that next time., if you check the above larger bulk of code you can see that the while loop extends down and closes later. thank you Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712488 Share on other sites More sharing options...
waterssaz Posted December 11, 2008 Share Posted December 11, 2008 do you have error reporting turned on? If so any errors on screen? :-) Quote Link to comment https://forums.phpfreaks.com/topic/136492-solved-slight-error-echoing-tables/#findComment-712491 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.