troubleshooting Question

Simple php / html Query

Avatar of powellt77
powellt77Flag for United Kingdom of Great Britain and Northern Ireland asked on
PHP
5 Comments2 Solutions217 ViewsLast Modified:
Hi All,

I'm super new to php and would like the answer to what I think would be a simple question.

I've managed to successfully create a working connection string to the mysql database, but I don't know how to display the results. The code (attached) is what I'm trying to achieve; query the table for everything and output into the table. The colum names match the table fields in the database.

Could someone show me how it should look?


<?php

$hostname="x";
$username="x";
$password="x";
$dbname="x";
$usertable="products";

mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
mysql_select_db($dbname);

$query = "Select * from products";

$result = mysql_query($query);

?>

<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled</title>
</head>

<body>

<table width="859" border="1" cellspacing="5" cellpadding="0" align=center>

<tr>
  	<td width="73"><div align="center"><font face="Arial" class="style15"><strong>ID</strong></font></div></td>
	<td width="169"><div align="center"><font face="Arial" class="style15"><strong>ProductType</strong></font></div></td>
    <td width="190"><div align="center"><font face="Arial" class="style15"><strong>ProductName</strong></font></div></td>
    <td width="150"><div align="center"><font face="Arial" class="style15"><strong>SmallPic</strong></font></div></td>
    <td width="110"><div align="center"><font face="Arial" class="style15"><strong>Price</strong></font></div></td>
    <td width="118"><div align="center"><font face="Arial" class="style15"><strong>Active</strong></font></div></td>
  </tr>
<tr>
	<td class="style11"><div align="center"><font face="Arial" size=2></font></div></td>
	<td class="style11"><div align="center"><font face="Arial" size=2></font></div></td>
    <td class="style11"><div align="center"><font face="Arial" size=2></font></div></td>
    <td class="style11"><div align="center"><font face="Arial" size=2></font></div></td>
    <td class="style11"><div align="center"><font face="Arial" size=2></font></div></td>
    <td class="style11"><div align="center"><font face="Arial" size=2></font></div></td>
  </tr>
</table>

</body>
</html>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros