How to format/style SQL results page returned by PHP

Posted on 2011-09-13
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?
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.CSS HTML Help 3 51
JSON help 8 40
Javascript image manipulationcrop-image 7 35
center div inside another div 2 29
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

740 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