tracy Posted December 1, 2006 Share Posted December 1, 2006 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body><!--pinclude "connectionpage.php";$query="SELECT * FROM 'Inventory'";$result=mysql_query($query);//where table name is Inventory$num=mysql_numrows($result);<table border="0" cellspacing="2" cellpadding="2"><tr><th><font face="Arial, Helvetica, sans-serif">Stock#</font></th> <th><font face="Arial, Helvetica, sans-serif">Year</font></th> <th><font face="Arial, Helvetica, sans-serif">Make</font></th> <th><font face="Arial, Helvetica, sans-serif">Model</font></th> <th><font face="Arial, Helvetica, sans-serif">Price</font></th> <th><font face="Arial, Helvetica, sans-serif">Miles</font></th> <th><font face="Arial, Helvetica, sans-serif">Photo</font></th> </tr>"<!--$i=0;while ($i < $num) {$stock=mysql_result($result,$i,"stock");$year=mysql_result($result,$i,"year");$make=mysql_result($result,$i,"make");$model=mysql_result($result,$i,"model");$price=mysql_result($result,$i,"price");$miles=mysql_result($result,$i,"miles");$photo=mysql_result($result,$i,"photo1");<tr><td><font face="Arial, Helvetica, sans-serif"><!--cho $stock;--></font></td><td><font face="Arial, Helvetica, sans-serif"><!--cho $year;--></font></td><td><font face="Arial, Helvetica, sans-serif"><!--cho $make;--></font></td><td><font face="Arial, Helvetica, sans-serif"><!--cho $model;--></font></td><td><font face="Arial, Helvetica, sans-serif"><!--cho $price;--></font></td><td><font face="Arial, Helvetica, sans-serif"><!--cho $miles;--></font></td><td><font face="Arial, Helvetica, sans-serif"><!--cho $photo1;--></font></td></tr><!--$i++;}echo "</table>";?></body></html> Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 2, 2006 Share Posted December 2, 2006 It could be that you have no opening tag for the PHP code. You also have no error handling to check for errors. Try this:[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body><?phpinclude "connectionpage.php";$query="SELECT * FROM 'Inventory'";$result = mysql_query($sql) or die ("The query:<br>".$query."<br>produced the following error:<br>".mysql_error());if (!mysql_num_rows($result)) { echo "there were no results.";} else { echo "<table border=1>"; $firstRecord = true; while ($row = mysql_fetch_assoc($result)) { if ($firstRecord) { echo "<tr>"; foreach ($row as $key => $value) {echo "<td>".$key."</td>";} echo "</tr>"; $firstRecord = false; } echo "<tr>"; foreach ($row as $value) { echo "<td>".$value."</td>"; } echo "</tr>"; } echo "</table><br>";}?></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
tracy Posted December 2, 2006 Author Share Posted December 2, 2006 Thanks.The query:SELECT * FROM 'Inventory'produced the following error:Query was emptyI don't know what this means...there is data in the table... Quote Link to comment Share on other sites More sharing options...
ataria Posted December 2, 2006 Share Posted December 2, 2006 [code]<?phpinclude ("connectionpage.php");$query= mysql_query("SELECT * FROM `Inventory`");$num = mysql_num_rows($query);if ($num == '0') {echo "Nothing Exist.";die();}else {echo "<table border="0" cellspacing="2" cellpadding="2"><tr><td><font face=Arial>Stock#</font></td><td><font face=Arial>Year</font></td><td><font face=Arial>Make</font></td><td><font face=Arial>Model</font></td><td><font face=Arial>Price</font></td><td><font face=Arial>Miles</font></td><td><font face=Arial>Photo</font></td></tr>";while ($info = mysql_fetch_array($query)) {$stock = $info['stock'];$year = $info['year'];$make = $info['make'];$model = $info['model'];$price = $info['price'];$miles = $info['miles'];$photo1 = $info['photo1'];echo "<tr><td> <font face=Arial> $stock</font></td><td> <font face=Arial> $year</font></td><td> <font face=Arial> $make</font></td><td> <font face=Arial> $model</font></td><td> <font face=Arial>$price</font></td><td> <font face=Arial> $miles</font></td><td> <font face=Arial> $photo1</font></td></tr>"}echo "</table>";}?>[/code] Quote Link to comment Share on other sites More sharing options...
tracy Posted December 2, 2006 Author Share Posted December 2, 2006 I tried that earlier...error line 17 which is where the table starts...echo "<table border...thanks, though...just tried it again and now error on line 17...same place. Quote Link to comment Share on other sites More sharing options...
ataria Posted December 2, 2006 Share Posted December 2, 2006 echo "<table border="0" cellspacing="2" cellpadding="2">change to..echo "<table border=0 cellspacing=2 cellpadding=2> Quote Link to comment Share on other sites More sharing options...
tracy Posted December 2, 2006 Author Share Posted December 2, 2006 now it says error line 56, right after the } symbol at the bottom, about three or four lines from the bottom... Quote Link to comment Share on other sites More sharing options...
jsladek Posted December 2, 2006 Share Posted December 2, 2006 Put a [b];[/b] after the [b]</tr>"[/b]</tr>"; Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 2, 2006 Share Posted December 2, 2006 You can mess with the HTML output all you want, but if your query is failing you still won't get any output!Either you are not connecting to the database or the table name is incorrect. I'm not sure that your include statement will work the way it is written. Try changing it to the correct format like this:include ("connectionpage.php");If that doesn't work, post the code from that included page. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 2, 2006 Share Posted December 2, 2006 The query should be:[code]<?php$query="SELECT * FROM Inventory";?>[/code]You don't need any quotes here.Ken Quote Link to comment Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 After all your suggestions, here's the new code:[code]<?phpinclude ("link.php");$query= mysql_query("SELECT * FROM 'Inventory'");$num = mysql_num_rows($query);if ($num == '0') {echo "Nothing Exist.";die();}else {echo "<table border=0 cellspacing=2 cellpadding=2><tr><td><font face=Arial>Stock#</font></td><td><font face=Arial>Year</font></td><td><font face=Arial>Make</font></td><td><font face=Arial>Model</font></td><td><font face=Arial>Price</font></td><td><font face=Arial>Miles</font></td><td><font face=Arial>Photo</font></td></tr>";while ($info = mysql_fetch_array($query)) {$stock = $info['stock'];$year = $info['year'];$make = $info['make'];$model = $info['model'];$price = $info['price'];$miles = $info['miles'];$photo1 = $info['photo1'];echo "<tr><td> <font face=Arial> $stock</font></td><td> <font face=Arial> $year</font></td><td> <font face=Arial> $make</font></td><td> <font face=Arial> $model</font></td><td> <font face=Arial>$price</font></td><td> <font face=Arial> $miles</font></td><td> <font face=Arial> $photo1</font></td></tr>";?>[/code]Here's the new error:Parse error: syntax error, unexpected $end in /home/inv/public_html/display3.php on line 58I feel I am connecting to the database, and my server seems to require the ' before and after the database name. Thanks... Quote Link to comment Share on other sites More sharing options...
trq Posted December 4, 2006 Share Posted December 4, 2006 You are missing the closing } to your while(). And no, you do NOT need quotes around the TABLE name. Quote Link to comment Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 I actually took it out. Now when I put it back in, I get the error which caused me to take it out...Parse error: syntax error, unexpected $end in /home/inv/public_html/display3.php on line 58Thanks for any suggestions... Quote Link to comment Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 Any thoughts? Thanks. Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 5, 2006 Share Posted December 5, 2006 You are missing two right curly braces ( } ). You need one to close the while loop and another to close the else condition. Quote Link to comment Share on other sites More sharing options...
tracy Posted December 5, 2006 Author Share Posted December 5, 2006 Parse error: syntax error, unexpected '>' in /home/inv/public_html/display.php on line 16This is what happens when the code looks like this with the right curly brackets...<?phpinclude ("link.php");$query= mysql_query("SELECT * FROM Inventory");$num = mysql_num_rows($query);if ($num == '0') {echo "Nothing Exist.";die();}else {echo '<table border="0" cellspacing="2" cellpadding="2">'<td><font face=Arial>Stock#</font></td><td><font face=Arial>Year</font></td><td><font face=Arial>Make</font></td><td><font face=Arial>Model</font></td><td><font face=Arial>Price</font></td><td><font face=Arial>Miles</font></td><td><font face=Arial>Photo</font></td></tr>";while ($info = mysql_fetch_array($query)) {$stock = $info['stock'];$year = $info['year'];$make = $info['make'];$model = $info['model'];$price = $info['price'];$miles = $info['miles'];$photo1 = $info['photo1'];echo "<tr><td> <font face=Arial> $stock</font></td><td> <font face=Arial> $year</font></td><td> <font face=Arial> $make</font></td><td> <font face=Arial> $model</font></td><td> <font face=Arial>$price</font></td><td> <font face=Arial> $miles</font></td><td> <font face=Arial> $photo1</font></td></tr>"}echo "</table>";}?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 6, 2006 Share Posted December 6, 2006 Might be a problem in your include file. Quote Link to comment Share on other sites More sharing options...
tracy Posted December 6, 2006 Author Share Posted December 6, 2006 the include file is working fine because I used it in some other php pages and they work fine. thanks though. Quote Link to comment 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.