jdooley Posted September 28, 2009 Share Posted September 28, 2009 This query works in phpMyadmin, but when I try to display it in a web browser, it doesn't work. <!-- FILENAME: "display.php"--> <html> <body> <?php //all PHP code starts with <?php // Connects to your Database mysql_connect("mysql4.freehostia.com","jerdoo_dooley","password") or die(mysql_error()); //opens the mysql account called "jdooley" with password "jd" //stored on the same server as this file ("localhost") mysql_select_db("jerdoo_dooley") or die(mysql_error()); //selects the database called "jdooley" $data = mysql_query("SELECT o.Order_No,po.Product_ID,po.Quantity,r.First_Name,r.Last_Name,r.ID,p.Product_ID,p.Description,p.Size,p.Price FROM `po`,`r`,`p`,`o` WHERE r.ID=o.ID AND o.Order_No=po.Order_No AND p.Product_ID=po.Product_ID ")or die(mysql_error()); //selects all fields ("*") from the table called "customers" echo "<table border=1>\n"; //creates a HTML table to display the First Name and Surname echo "<tr><td>Order_No</td><td>Product_ID<td>Quantity</td><td>First Name</td><td>Last Name</td><td>Registration Number</td><td>Product Code</td><td>Description</td><td>Size</td><td>Price</tr>\n"; //The column headings in this table are First Name and Surname while($info = mysql_fetch_array( $data )) //Uses a "while" loop to display all the records in the customers table { Print "<tr>"; Print "<td>".$info['o.Order_No'] . "</td> "; // displays the First Names in the first (First Name) column Print "<td>".$info['po.Product_ID'] . "</td> "; Print "<td>".$info['po.Quantity'] . "</td> "; Print "<td>".$info['r.First_Name'] . "</td> "; Print "<td>".$info['r.Last_Name'] . "</td> "; Print "<td>".$info['r.ID'] . "</td> "; Print "<td>".$info['p.Product_ID'] . "</td> "; Print "<td>".$info['p.Description'] . "</td> "; Print "<td>".$info['p.Size'] . "</td> "; Print "<td>".$info['p.Price'] . " </td></tr>"; // displays the Surnames in the second (Second Name) column } Print "</table>\n"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/175860-mysql-query-wont-display-in-a-web-browser/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 28, 2009 Share Posted September 28, 2009 Define: "it doesn't work" That provides absolutely no helpful information about what you saw in front of you when you tried it that anyone else would need in order to help you. For all we know, you don't even have php installed on a web server. Link to comment https://forums.phpfreaks.com/topic/175860-mysql-query-wont-display-in-a-web-browser/#findComment-926643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.