Formatting Data
Moderator: General Moderators
-
after_shox
- Forum Newbie
- Posts: 13
- Joined: Wed Mar 10, 2004 11:53 am
Formatting Data
I am building up a query with php that gets data from mysql and displays it in some nice preformated html tables i have made. It works good but i want to be able to position the boxes ( tables ) exactly where i want them. Im currently using a while loop and an echo statement to print out all of the rows into the boxes but this just prints them one after the other in a big long line. So im thinking im not doing it the right way. Any help appreciated 
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
-
after_shox
- Forum Newbie
- Posts: 13
- Joined: Wed Mar 10, 2004 11:53 am
erm my guess if I am thinking the way sami described it:
Code: Select all
<?php
$sql = "SECECT * FROM table_name";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$user = $row["user"];
// now user would be a row in your table inside your database
?>-
after_shox
- Forum Newbie
- Posts: 13
- Joined: Wed Mar 10, 2004 11:53 am
oh sorry for the misunderstanding.
There are a few approaches, but save yourself the time.
Add a "id" column toy our table and set it as Primary key and auto_inc.
that way when a new row of data comes into the table, it will add one from the previous row, n call it like so:
Thats the way most people do it, MySQL is awesome, use it to its full capabilites.
There are a few approaches, but save yourself the time.
Add a "id" column toy our table and set it as Primary key and auto_inc.
that way when a new row of data comes into the table, it will add one from the previous row, n call it like so:
Code: Select all
<?php
$sql = "SELECT FROM table_name WHERE id='$id'";
?>