Connecting Tech Pros Worldwide Forums | Help | Site Map

Fill tables

savanm's Avatar
Member
 
Join Date: Oct 2006
Location: chennai
Posts: 86
#1: Mar 6 '07
Hi all,

I have a table like this username passworrd
abcd abcd
dsadas fdfdsfds

I want to load the list of the above table in to my html table..
that is

in firstrow,firstcolum of the table abcd
firstrow second column of the table abcd
secondrow,firstcolumn dsadas
secondrow,secondcolumn fdfdsfds


Any one please help me

Regards..,
Navas.M

savanm's Avatar
Member
 
Join Date: Oct 2006
Location: chennai
Posts: 86
#2: Mar 6 '07

re: Fill tables


i explain briefly here

the table in database contains two fields namely username and password

I want to display this as in my html table

<tr>
<td>username</td>
<td>password</td>
</tr>

Regards
Navas.M
Member
 
Join Date: Sep 2006
Location: Dhaka, Bangladesh
Posts: 53
#3: Mar 6 '07

re: Fill tables


Hi try this code:
[PHP]
<?
$sql = mysql_query("select * from TABLE_NAME");
$res = mysql_fetch_assoc($sql);

echo "<table width='300' border='0' cellspacing='0' cellpadding='0'>"
while ($myrow = mysql_fetch_array($result))
{
echo"<tr><td>";
echo "User Name: ";
echo "</td><td>"
echo $myrow['username'];
echo "</td></tr><tr><td>";
echo "Password</td><td>";
echo $myrow['password'];
echo "</td></tr>"
}
echo "</table>";
?>
[/PHP]
savanm's Avatar
Member
 
Join Date: Oct 2006
Location: chennai
Posts: 86
#4: Mar 6 '07

re: Fill tables


Hi mainul,,

thanks for ur guidence..

it helped me 2 achieve my goal

I use the code like this

<?php
$sql = "select * from login";
$ress = mysql_query($sql);

echo ("<table name='data' height='21' width='24' cellpadding='3' cellspacing='3' align='center' bordercolor='black' border='1' bgcolor='#45509C'>");
echo "<td>User Name:</td>";

echo "<td>Password</td>";
while($row = mysql_fetch_array($ress))
{


echo "<tr>";


echo ("<td>'$row[user]'</td>");

// echo "</tr>";



// echo"<tr>";



echo ("<td>'$row[password]'</td>");

echo "</tr>";

}

echo "</table>";

?>
Reply