Jump to content

Recommended Posts

Hi,

 

Need some advises or quick help with my query result layout (attached to this post)

 

I'm currently using this code to organize and show my query's result

 

	echo '<tr><th>NAME</th><th>TYPE</th><th>POSITION</th><th>DEFAULT</th><th>LENGHT</th><th>IS NULLABLE</th><th>NUMERIC PRECISION</th><th>NUMERIC SCALE</th></tr>';

// Retrieve individual rows from the result
while ($row1 = sqlsrv_fetch_array($qresult1,SQLSRV_FETCH_NUMERIC)) {

$QueryResults1[$row1['0']] = $row1;
$QueryResults1[$row1['1']] = $row1;
$QueryResults1[$row1['2']] = $row1;
$QueryResults1[$row1['3']] = $row1;
$QueryResults1[$row1['4']] = $row1;
$QueryResults1[$row1['5']] = $row1;
$QueryResults1[$row1['6']] = $row1;
$QueryResults1[$row1['7']] = $row1;


	echo '<tr><td>', htmlspecialchars($row1['0']),
		 '</td><td>', htmlspecialchars($row1['1']),
		 '</td><td>', htmlspecialchars($row1['2']),
		 '</td><td>', htmlspecialchars($row1['3']),
		 '</td><td>', htmlspecialchars($row1['4']),
		 '</td><td>', htmlspecialchars($row1['5']),
		 '</td><td>', htmlspecialchars($row1['6']),
		 '</td><td>', htmlspecialchars($row1['7']),
		 "</td></tr>\n";
}

 

and

 

	echo '<tr><th>NAME</th><th>TYPE</th><th>POSITION</th><th>DEFAULT</th><th>LENGHT</th><th>IS NULLABLE</th><th>NUMERIC PRECISION</th><th>NUMERIC SCALE</th></tr>';

// Retrieve individual rows from the result
while ($row2 = sqlsrv_fetch_array($qresult2,SQLSRV_FETCH_NUMERIC)) {

$QueryResults2[$row2['0']] = $row2;
$QueryResults2[$row2['1']] = $row2;
$QueryResults2[$row2['2']] = $row2;
$QueryResults2[$row2['3']] = $row2;
$QueryResults2[$row2['4']] = $row2;
$QueryResults2[$row2['5']] = $row2;
$QueryResults2[$row2['6']] = $row2;
$QueryResults2[$row2['7']] = $row2;

	echo '<tr><td>', htmlspecialchars($row2['0']),
		 '</td><td>', htmlspecialchars($row2['1']),
		 '</td><td>', htmlspecialchars($row2['2']),
		 '</td><td>', htmlspecialchars($row2['3']),
		 '</td><td>', htmlspecialchars($row2['4']),
		 '</td><td>', htmlspecialchars($row2['5']),
		 '</td><td>', htmlspecialchars($row2['6']),
		 '</td><td>', htmlspecialchars($row2['7']),
		 "</td></tr>\n";
}

 

Of course, that's the relevant part of the code. The query and connection not included.

 

I would like to maybe use css, better fonts or even color. It actually looks boring and ugly. What markup code should I use or how can I modify that part of the code so I can get a more professional or easy to read display?

 

post-131195-13482403233656_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/256847-help-with-html-layout-of-query-result/
Share on other sites

Stick this in your head:

<link href="styles.css" rel="stylesheet" type="text/css">

 

Then create a file called styles.css and use that to style your page.

 

For instance:

th {
color: blue;
}

td {
color: red;
}

 

Or whatever you want to do.  You can change colors, fonts, add margins and padding, etc.  You'll have to be a little more descriptive of what you want done.

1st,

 

Thanks for the MOD which moved it to the right forum :-)

 

Now, to dmikester1, appreciate your response.

 

My CSS knowledge is very limited, but I used to code pure HTML back in 1994 (yeah, maybe I'm older than you, lol) so I can catch up concepts quickly. I'm actually a professional DBA.

 

What I am trying to accomplish is make a clear distinction between the headers and the content. Also, I would like to experiment with some type of grid, like creating a table? So results can be easier to read. Not so sure how it will look like, that's why I want to play a little bit.

 

But I don't know how to generate such grid. However, you gave me a basic idea of how change color for text and headers.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.