using html to position results

P

patrick_woflian

Hey, i have set up a website which allows users to search for other
members. This code is in php and works fine, however.. to make the
layout more attractive i was thinking of using html code segments to
position the results in a table for example. Here is the php code, any
ideas how to make the layout more attractive????

<?php
$connection = mysql_connect("sentinel.cs.cf.ac.uk","scm5sjc",
"MyPasswordGoesHere");

mysql_select_db("sjcdb",$connection) or die("failed!");

$result = mysql_query("SELECT * FROM info", $connection);

while($row = mysql_fetch_row($result)) {

$title = $row[1];
$first = $row[2];
$last = $row[3];
$age = $row[4];
$subject = $row[5];
$initial=$row[6];
$email=$row[7];

for ($i=0; $i<mysql_num_fields($result); $i++) print $row[$i]." ";
echo "\n";
print $title." ";
print $first_name." ";
print $last_name ." ";
print $age ." ";
print $subject." ";
print $initial." ";
print $email." ";

}

mysql_close($connection);
?>

Cheers
Steven
 
J

Jim Moe

patrick_woflian said:
Hey, i have set up a website which allows users to search for other
members. This code is in php and works fine, however.. to make the
layout more attractive i was thinking of using html code segments to
position the results in a table for example. Here is the php code, any
ideas how to make the layout more attractive????
You're just kidding, right???? How are we to view this table without
PHP???? Or Mysql???? Or database access???? Or the data in the database????
Post an URL showing your test case.
 
T

Toby Inkster

patrick_woflian said:
Hey, i have set up a website which allows users to search for other
members. This code is in php and works fine, however.. to make the
layout more attractive i was thinking of using html code segments to
position the results in a table for example.

How about something like this?

print "<table>\n";
while ($row = mysql_fetch_row($result))
{
$class = ($class=='a')?'b':'a';
$line = implode('</td><td>', $row);
$line = "<tr class=\"$class\"><td>$line</td></tr>\n";
}
print "</table>\n";

with this:

<style type="text/css">
TABLE { border: 2px solid; border-collpase: collapse; }
TR.a TD { color: black; background: #eee; border: 1px solid; }
TR.c TD { color: black; background: #ffd; border: 1px solid; }
</style>
 
J

Jonathan N. Little

Toby Inkster wrote:
How about something like this?

print "<table>\n";
while ($row = mysql_fetch_row($result))
{
$class = ($class=='a')?'b':'a';
$line = implode('</td><td>', $row);
$line = "<tr class=\"$class\"><td>$line</td></tr>\n"; print $line;
}
print "</table>\n";

with this:

<style type="text/css">
TABLE { border: 2px solid; border-collpase: collapse; }
TR.a TD { color: black; background: #eee; border: 1px solid; }
<strike> TR.c TD { color: black; background: #ffd; border: 1px solid;
} said:

Small tweaks ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top