Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

styling mysql results

Status
Not open for further replies.

benluke4

Technical User
Jan 27, 2005
127
GB
Thought i should start a new thread.

i'm wondering now how to style my results, maybe putting a line break between the results and styling the text using something like <p class="body">(which is already defined) also verifying the width of the table etc...

Im not sure how to work it into this php code

Code:
echo "<br>";
echo "<br>";
echo "<table>\n";

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

   echo "</td><td>" . $row['category'] .
        "</td><td>" . $row['company'] .
        "</td><td>" . $row['name'] .
        "</td><td>" . $row['web_address'] .
        "</td><td>" . $row['email_address'] .
        "</td><td>" . $row['tel'] .
        "</td><tr>\n";
}
echo "</table>\n";

Thanks for any advice

Ben
 
i like to separate the html and php tags and not echo the HTML tags. its a matter of choice. here's a change:

<table>
<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<tr><td><?=$row['category']?></td>
<td><?=$row['company']?></td>
<td><?=row['name']?></td>
<td><?=$row['web_address']?></td>
<td><?=$row['email_address']</td>
<td><?=$row['tel']?></td>
</tr>
<?
}
?>
</table>
 
i like your way, so much clearer to understand.

ill give it a go and see how i get on

Thanks

kaancho12
 
this works great
but how do i add <a href="mailto:> to the email_address and <a href="http:> to the web address.

I keep getting errors and cant work out how to place them within the code

Thanks again

Ben
Code:
<table class="results">
<?php
   while ($row = mysql_fetch_assoc($result)) {
?>
   <tr><td><p class="body"><?=$row['category']?></p></td></tr>
   <tr><td><p class="body"><?=$row['company']?></p></td></tr>
   <tr><td><p class="body"><?=$row['name']?></p></td></tr>
   <tr><td><p class="body"><?=$row['web_address']?></p></td></tr>
   <tr><td><p class="body"><?=$row['email_address']?></p></td></tr>
   <tr><td><p class="body"><?=$row['tel']?></p></td></tr>
<?
}
?>
</table>
 
SORRY my mistake, its fine

<tr><td><p class="body">Email:<a href="mailto:"><?=$row['email_address']?></a></p></td></tr>

Thanks

Ben
 
ok , its not fine.

Although they show as a link they link nowhere could someon show me how its done.

Thanks

Ben

this is what i am using at the moment
Code:
<table class="results">
<?php


   while ($row = mysql_fetch_assoc($result)) {
?>
   <tr><td><p class="body">Category:<?=$row['category']?></p></td></tr>
   <tr><td><p class="body">Company:<?=$row['company']?></p></td></tr>
   <tr><td><p class="body">Contact Name:<?=$row['name']?></p></td></tr>
   <tr><td><p class="body">Website:<a href="[URL unfurl="true"]http://"><?=$row[/URL]['web_address']?></a></p></td></tr>
   <tr><td><p class="body">Email:<a href="mailto:"><?=$row['email_address']?></a></p></td></tr>
   <tr><td><p class="body">Telephone:<?=$row['tel']?></p></td></tr>
<?
}
?>

Thanks
 
jeez, it ain't rocket science

Code:
<tr><td><p class="body">Website:<a href="[URL unfurl="true"]http://<?=$row[/URL]['web_address']?>"><?=$row['web_address']?></a></p></td></tr>
   <tr><td><p class="body">Email:<a href="mailto:<?=$row['email_address']?>"><?=$row['email_address']?></a></p></td></tr>

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
good job i dont like science or rockets then!

Thanks
 
Put in the reference (that will be linked) like:
Code:
<tr><td><p class="body">Website:<a href="[URL unfurl="true"]http://"><?=$row[/URL]['web_address']?>[COLOR=red]Click here to visit <?=$row['company']?> web Site[/color]</a></p></td></tr>
   <tr><td><p class="body">Email:<a href="mailto:"><?=$row['email_address']?>[COLOR=red]Click here to send an email[/color]</a></p></td></tr>
Also, the <p> tags aren't really needed (they're ok, but you can style without them.)
e.g.
Code:
<tr><td  class="category">Category: <?=$row['category']?></td></tr>
<tr><td class="company">Company: <?=$row['company']?></td></tr>
OR you could just style all <td> in your stylesheet
Code:
td {font-weight: bold;	background-color: #EEBB66;
etc. etc.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Thanks Greg,

styling the td's seems like a good idea!

Ben
 
I love when two responses get written in the time it takes me to type. [smile]


Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top