How to display data in my html table

Hi,

I have created my html table, which i want to display the data that i have already inserted.can anyone tell me how to do it?for now i can display my data, :frowning: but without the table…but this way i don’t have a clue how to do it,what do i have to do???can any one help me???

[php]

Main Client Detail Form
<th><input type="submit" name="ADD" value="ADD" onClick="window.location.href='client1.php'">
	<input type="submit" name="EDIT" value="EDIT" onClick="window.location.href='client1.php'"></th>
<th colspan="2"><input type="submit" name="DELETE" value="DELETE" onClick="window.location.href='client2.php'"></th>
 <th colspan="2"><input type="submit" name="MAIN" value="MAIN"  onclick="window.close()"></th>
Select Client ID Client Name Address Telephone Fax
[/php]

where is this data stored?

I don’t understand what you are trying to do…

Do you want to display the data you have previously stored into db? Or do you want to display some list of all the clients who submitted data to the db (ie client database list in nice table)?

Or you might want to display what someone just submitted in some form (let’s say a confirmation of what he entered)?

I have already built a database -‘sd’ and in it there is a table -‘client’.

[php]

Untitled Document <?php $username="root"; $password=""; $database="sd"; //connect to sever $connect = mysql_connect("localhost",$username,$password) or die("sever doesn't exist"); //connect to database mysql_select_db('sd') or die("database doesn't exist"); $query = "SELECT * FROM client"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); /* Printing results in HTML */ echo "
\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t\n"; foreach ($line as $col_value) { echo "\t\t\n"; } echo "\t\n"; } echo "
$col_value
\n"; /* Free resultset */ mysql_free_result($result); ?> [/php]

For now i can select all and can show the data in my browser.But i want to show it in my HTML table…

[php]

Main Client Detail Form
<th><input type="submit" name="ADD" value="ADD" onClick="window.location.href='client1.php'">



Select Client ID Client Name Address Telephone Fax
[/php]

can anyone tell me how to do…

I’m a little confused… you’re already putting it in a table here:

foreach ($line as $col_value) {
echo “\t\t

$col_value\n”;
}

You can also do it as follows:

<?php echo $line['column_name']; ?>

I’m just confused what you’re asking…

Thanks i created what i wanted. :slight_smile:

[php]

Untitled Document <?php $username="root"; $password=""; $database="sd"; //connect to sever $connect = mysql_connect("localhost",$username,$password) or die("sever doesn't exist"); //connect to database mysql_select_db("sd") or die("database doesn't exist"); $result = mysql_query("SELECT * FROM client") or die("Query failed : " . mysql_error()); //creating a table echo "
"; // loop to show records on DB in a table // while($row = mysql_fetch_array($result)) { echo "";// echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } { echo "" ; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
Select Client ID Client Name Address Telephone Fax
" . "" . "" . $row['ClientID'] . "" . $row['ClientName'] . "" . $row['Address'] . "" . $row['Telephone'] . "" . $row['Fax'] . "
" . "" ."" ."" . "" ."" . "" . "" . "" . "" . "
"; ?> [/php]

It works fine…but my question is this table will come in a separate window after i click a link.how to adjust the window according to the displaying table??? is there a way?cause now I’m getting a window which i need to re-size a little bit…Can anyone help Please… Thanks… :slight_smile:

to open a page in a new window with the link would be like: , if you’re wanting to resize the window I believe that has to be done with javascript something like:
[php]

You're table here
[/php] I found this on another site so it's not tested but looks like it should work. :)
Sponsor our Newsletter | Privacy Policy | Terms of Service