|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi!
I would like to know how I can format my mysql results into a nice little table. PHP Code:
The results should be spit out in this: (where name is $user and bio is $bio) Code:
<table> <tr> <td>Name<br> Bio</td> <td>Name (Diffrent user)<br> Bio (Diffrent user)</td> <td>ect</td> <td>ect</td> </tr> <tr> <td>ect</td> <td>ect</td> <td>ect</td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> How could I do this? How would it look code-wise? thanks in advanced. Im pretty new to all this. |
|
#2
|
|||
|
|||
|
Hope this helps
Quote:
There are two ways of doing this: Solution 1 Code:
<table> <tr> <td><?php echo $user; ?><br> <?php echo $bio; ?></td> <td>Name (Diffrent user)<br> Bio (Diffrent user)</td> <td>ect</td> <td>ect</td> </tr> <tr............. Solution 2 Code:
<?php
echo "
<table>
<tr>
<td>$user<br>
$bio</td>
<td>Name (Diffrent user)<br>
Bio (Diffrent user)</td>
<td>ect</td>
<td>ect</td>
</tr>
<tr.............
";
?>
Be advised when using the second solution certain characters will need to be formatted differently within the echo. ie. (" will be \"). Unless you're familiar with PHP I would use the first solution. Check out php.net documentation for any questions. |
|
#3
|
|||
|
|||
|
Thanks
![]() But, wouldnt it be something like foreach $user + $bio; echo <td>$user <br> $bio</td> |
|
#4
|
|||
|
|||
|
Quote:
No, whitespace is irrelevant |
|
#5
|
|||
|
|||
|
thank you, thank you, thank you!!
For now it works. I still need to do some testing, but with three Names + Bios are already up and running this way. How could I insert the next 4 results into a new row? (sorry if im being a very very annoying newbie) |
|
#6
|
|||
|
|||
|
Quote:
It's Ok, everyone is a n00b at some point. Try this: PHP Code:
You will need to adapt this to your own needs, but that script will create a table. In the table it will create as many rows as needed, depending on how many different rows are returned from your query. |
|
#7
|
|||
|
|||
|
Thanks everyone!
It still doesnt quite work, but heres what I have till now. Its not doing anything, but I believe it would work. ...If I would know what I'm doing wrong: PHP Code:
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Formating sql result (in table) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|