PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
AVanover5
Forum Newbie
Posts: 3 Joined: Mon Feb 21, 2011 3:00 pm
Post
by AVanover5 » 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
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>
query.php
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);
?>
crazycoders
Forum Contributor
Posts: 260 Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada
Post
by crazycoders » Mon Feb 21, 2011 3:41 pm
I dont' see the result of your problem neither do i see what is the specific problem?
Do you have a result i can see and analyse cause it doesn'T seem to output any error for now!
AVanover5
Forum Newbie
Posts: 3 Joined: Mon Feb 21, 2011 3:00 pm
Post
by AVanover5 » Mon Feb 21, 2011 4:19 pm
crazycoders wrote: I dont' see the result of your problem neither do i see what is the specific problem?
Do you have a result i can see and analyse cause it doesn'T seem to output any error for now!
The problem is a lack of output. The inline CSS in one of the echo functions isn't rendering. Try the script on your host by changing 'anthonyvanover.zxq.net'. Then run a query from the form, like the following:
Make sure there is an SQL entry that'll be longer than 100px when rendered in HTML. This way, we can tell if the CSS overflow property is rendering.
AVanover5
Forum Newbie
Posts: 3 Joined: Mon Feb 21, 2011 3:00 pm
Post
by AVanover5 » Tue Feb 22, 2011 3:09 pm
AVanover5 wrote: crazycoders wrote: I dont' see the result of your problem neither do i see what is the specific problem?
Do you have a result i can see and analyse cause it doesn'T seem to output any error for now!
The problem is a lack of output. The inline CSS in one of the echo functions isn't rendering. Try the script on your host by changing 'anthonyvanover.zxq.net'. Then run a query from the form, like the following:
Make sure there is an SQL entry that'll be longer than 100px when rendered in HTML. This way, we can tell if the CSS overflow property is rendering.
I just realized the problem. The content has to be in a "div" tag for the CSS to render... Here's what it was basically producing before:
Code: Select all
<center><h3>Query completed successfully</h3></center><br/>
<table border='1'>
<tr>
<td style="overflow: auto; height: 100px;">ID</td>
<td style="overflow: auto; height: 100px;">Date</td>
<td style="overflow: auto; height: 100px;">Content</td>
</tr>
<tr>
<td style="overflow: auto; height: 100px;">1</td>
<td style="overflow: auto; height: 100px;">02.22.2011</td>
<td style="overflow: auto; height: 100px;">Really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really Really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really looooooooooooooong ESS KYOO ELL entry!!!</td>
</tr>
But in order to get the effect that I want, I need to put a "div" within "td" and use the styling on that, rather than the cell itself...