Solved

How to format/style SQL results page returned by PHP

Posted on 2011-09-13
7
193 Views
Last Modified: 2012-05-12
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>
0
Comment
Question by:Ed_CLP
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:carsRST
ID: 36529281
You will not need to modify anything on the server.  Just add CSS particular to the table.

Link below walks you through that process.

http://www.w3schools.com/css/css_table.asp
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36529297
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" />
0
 

Author Comment

by:Ed_CLP
ID: 36529822
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?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 16

Expert Comment

by:carsRST
ID: 36530269
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
0
 

Accepted Solution

by:
Ed_CLP earned 0 total points
ID: 36550898
Perhaps I didn't describe the question correctly.  I am trying to retrieve results of a SQL query from an external server.  My understanding is that the external server needs to present the results as XML or JSON in order for me to be able to apply formatting to the results.  is this correct?
0
 

Author Closing Comment

by:Ed_CLP
ID: 36591853
I answered my own question.
0
 

Author Comment

by:Ed_CLP
ID: 36563828
question no longer active
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question