simple table or list formating

folks, I am real beginner , I want to display a list of data but a bit formated or even within a table this is my code it puts out a crude list of data I am already able to change color but no idea how to center it or put spaces in between the columns…it does display fine but needs formatting…thanks for any help

<?php echo ' '; echo 'body { background-color: #FFFFFF; } body, td, th { color: #000000; } h1 { color: #000000; } h2 { color: #000000; } h3, h4 { color: #000000; } h5, h6 { color: #000000; } a { color: #000000; } form { background-color: #990000; }'; echo ''; mysql_connect("", "databasename", "Password") or die("Connection Failed"); mysql_select_db("databasename")or die("Connection Failed"); $name = $_POST['name']; $query = "select * from student1 where name = '$name'"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $line['link']; echo $line['code']; echo "
\n"; } ?>

Here is how you can display query results in a table:
[php]echo ‘

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo ‘’;
echo ‘’;
echo ‘’;
echo ‘’;
echo ‘

thanks so much you are very kind, i will post the complet code a soon as I now that is working so that the rest of the beginners can get going

i started making a list with 4 colums, id, class, name, link, this table i made in with excel. use a few data for each column the id is just 1,2,3, class is used countries, name i used cities, link you can make a html hyperlink: starting with html and ending with html in between the normal code for a hyperlink, that will show in a list as a hyperlink. name the top row id, class, name and link and fill some data that you will than save as using the save as other formats in excel way below, i save it as csv (dos) as student1 on my desktop for later uploading in mysql. next step is to make a mysql talbe on the server side. if you have a hosting acccount with godaddy, you will open the account choose hosting with your domain already running on that hosting account, I choose, using deluxe hosting you will be able to have unlimited subfolders each of them containing another website with another domain, so on hosting pays for many many websites…I use html editor phase to make the code, good enough to start fooling around with html and php…i use fillezilla to upload the code onto godaddy server …it lets me see the folder structure so i can switch fairly fast from one website to another…
so than making the mysql talbe go to the hosting account of godaddy and you will see settings. open that open mysql, define your account call it student1 with password lets say student1, define a database table lets say student1 r, make a table called student1, define the colums with the names id, class, name , link, use varchar put it on 255. then after that import your csv file which you have on your desktop by pressing import in starfield godaddy myql , choose file from desktop, you will than choose csv with load data press ok, the data shoul load in your mysql database take a look if the data is there by choosing show data…if its there you have made a big leap towards using php mysql data query…so than you just have to make a webpage containg the display code that was now formatted in a simple way to make a table
this is the code to put on a simple empty page using phase editor and save it as php file lets name it student1.php so now we have a student1.php and well upload it with fillezilla to the server. check it out on the internet will show a box to enter the country to find, press display it will show a table with the link and the countries, countries are stored under name in the table.

<?php echo ' '; echo 'body { background-color: #FFFFFF;} body, td, th {color: #000000;} h1 { color: #000000;} h2 {color: #000000;} h3, h4 {color: #000000;} h5, h6 { color: #000000;} a {color: #000000;} form { background-color: #990000;}'; echo ''; mysql_connect("[b][/b]", "[b]yourusernamegoeshere[/b]", "[b]yourpasswordgoeshere[/b]") or die("Connection Failed"); mysql_select_db("y[b]ourdatabasenamegoeshere[/b]")or die("Connection Failed"); $name = $_POST['name']; $query = "select * from [b]youtablenamegoeshere[/b] where name = '$name'"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ''; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ''; echo ''; echo ''; echo ''; } echo '
'; echo "
\n"; } ?>

use a table with columns id, class, name, link than it should work

I started out with :

buying a domain on godaddy
buying a delux hosting godaddy
opening a database
creating a table

making the same table with excel
saving it as csv file
importing the csv file into the mysql tabel that already had the columns defined

how do you use css file to format the same table as shown on top, if you know where to include the css in this particular code that would be great it you could show me

Sponsor our Newsletter | Privacy Policy | Terms of Service