PHP-generated CSS
Posted: Mon Feb 21, 2011 3:32 pm
I have a form that does SQL queries on my host and displays any results in a table. My problem is, is that I can't seem to be able to use PHP-generated CSS. The engine parses the echo function just fine without error but the CSS doesn't render on the client side. I can't figure out why. Could you help me out? 
query.htm
query.php
query.htm
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>SQL Queries</title>
</head>
<body>
<center><form action="query.php" method="post">
Database: <input type="text" size="35" name="base"><br/>
Username: <input type="text" size="35" name="user"><br/>
Password: <input type="password" size="35" name="pass"><br/>
SQL query:<br/><textarea name="query" rows="4" cols="40"></textarea><br/>
<input type="submit">
</form></center>
</body>
</html>
Code: Select all
<?php
$user = $_POST["user"];
$pass = $_POST["pass"];
$base = $_POST["base"];
$query = $_POST["query"];
$link = @mysql_connect('anthonyvanover.zxq.net', $user, $pass);
if (!$link) {
die('Could not connect: ' . mysql_error());
mysql_close($link);
}
$db = @mysql_select_db($base);
if (!db) {
die('Unable to select database: ' . mysql_error());
mysql_close($link);
}
$result = @mysql_query($query);
$num = mysql_num_fields($result);
if (!$result) {
die('Invalid query: ' . mysql_error());
mysql_close($link);
}
echo "<center><h3>Query completed successfully</h3></center><br/>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$num; $i++) {
$field = mysql_fetch_field($result);
echo "<td style=\"overflow: auto; height: 100px;\">" . htmlspecialchars($field->name, ENT_QUOTES) . "</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result)) {
echo "<tr>";
// Put all $row to $cell
foreach($row as $cell)
echo "<td style=\"overflow: auto; height: 100px;\">" . htmlspecialchars($cell, ENT_QUOTES) . "</td>";
echo "</tr>\n";
}
mysql_free_result($result);
mysql_close($link);
?>