Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP & HTML

Status
Not open for further replies.

kizmar2

Programmer
Joined
May 25, 2004
Messages
164
Location
US
Is there any way I can get PHP to work with HTML in the manner I'm trying below? It's not working and I don't know if it just can't be done or if I'm missing something:

++++++++++++

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
<?php
$dbh = mysql_connect("localhost", "user", "password") or die("Failure to communicate with database");
mysql_select_db("test_db") or die(mysql_error());

$rs = mysql_query('SELECT * FROM test_table') or die(mysql_error());

$row = mysql_fetch_array($rs);

$header = $row['header'];
$rooms = $row['rooms'];
$sqft = $row['sqft'];
$price = $row['price'];

?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>test past</title>
</head>

<body>
<?php while (mysql_fetch_row($rs)): ?>
<table width="600" border="1" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><?php $_GET[$header]; ?></td>
</tr>
<tr>
<td><?php $_GET[$rooms]; ?></td>
<td><?php $_GET[$sqft]; ?></td>
<td><?php $_GET[$price]; ?></td>
</tr>
</table>
<?php endwhile; ?>
</body>
</html>
 
try:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>test past</title>
</head>

<body>
<?php
$dbh = mysql_connect("localhost", "user", "password") or die("Failure to communicate with database");
mysql_select_db("test_db") or die(mysql_error());

$rs = mysql_query('SELECT * FROM test_table') or die(mysql_error());
while ($row = mysql_fetch_row($rs)){
  echo "<table width=\"600\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\">
    <tr>
        <td colspan=\"3\">".$row['header']."</td>
    </tr>
    <tr>
        <td>".$row['rooms']."</td>
        <td>".$row['sqft']."<td>
        <td>".$row['price']."</td>
    </tr>
</table>"; 
}?>
</body>
</html>

Note, I did not test this out, it may e buggy.

___________________________________
--... ...--, Eric.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top