Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How to format/style SQL results page returned by PHP

Posted on 2011-09-13
Medium Priority
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

          <td>Column1 Header</td>
          <td>Column1 Header</td>
          <td>Column1 Header</td>
          <td>Column1 Header</td>
Question by:Ed_CLP
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 16

Expert Comment

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.

LVL 16

Expert Comment

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...

If you want to reference a file....

<link rel="stylesheet" type="text/css" href="myCSSFile.css" media="screen" />

Author Comment

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?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 16

Expert Comment

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.


<td style="background:#ccc; color:#fff;">Column1 Header</td>

Further explanation of inline styles:

Accepted Solution

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?

Author Closing Comment

ID: 36591853
I answered my own question.

Author Comment

ID: 36563828
question no longer active

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

609 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