Ed_CLP
asked on
How to format/style SQL results page returned by PHP
I have an HTML form which submits a POST statement containing a SQL query to a PHP server.
The results are returned as a generic HTML table (see example). Is it possible to add some CSS/AJAX to the results without having to modify the server-side pages? I would like to add some additional formatting to the results.
// source for page returned by PHP server
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td>Column1 Header</td>
<td>Column1 Header</td>
<td>Column1 Header</td>
<td>Column1 Header</td>
</tr>
<tr>
<td>840</td>
<td>2010-09-13</td>
<td>2011-09-09</td>
<td>-234262.900</td>
</tr>
</table>
</body>
</html>
The results are returned as a generic HTML table (see example). Is it possible to add some CSS/AJAX to the results without having to modify the server-side pages? I would like to add some additional formatting to the results.
// source for page returned by PHP server
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td>Column1 Header</td>
<td>Column1 Header</td>
<td>Column1 Header</td>
<td>Column1 Header</td>
</tr>
<tr>
<td>840</td>
<td>2010-09-13</td>
<td>2011-09-09</td>
<td>-234262.900</td>
</tr>
</table>
</body>
</html>
BTW - you can use the example below to put your CSS directly in to your page. The other alternative is to put your CSS in its own file and reference.
<STYLE TYPE="text/css">
...css text...
</STYLE>
If you want to reference a file....
<link rel="stylesheet" type="text/css" href="myCSSFile.css" media="screen" />
<STYLE TYPE="text/css">
...css text...
</STYLE>
If you want to reference a file....
<link rel="stylesheet" type="text/css" href="myCSSFile.css" media="screen" />
ASKER
I tried adding the <style... tags in the <head> section of my HTML page, but the PHP results are returned as a separate page. Would I have to embed the results in my original page?
I see what you're saying. Your best option may be to use inline styles. So that the table generated from your AJAX will have the styling embedded in it. that way it is sure to be rendered.
Example:
<td style="background:#ccc; color:#fff;">Column1 Header</td>
Further explanation of inline styles:
http://webdesign.about.com/od/beginningcss/qt/tipcssinlinesty.htm
Example:
<td style="background:#ccc; color:#fff;">Column1 Header</td>
Further explanation of inline styles:
http://webdesign.about.com/od/beginningcss/qt/tipcssinlinesty.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I answered my own question.
ASKER
question no longer active
Link below walks you through that process.
http://www.w3schools.com/css/css_table.asp