create table test
(
name varchar(20),
gender varchar(20),
salary varchar(20)
);
insert into test values ('nm1','male','20000');
insert into test values ('nm2','female','85000');
insert into test values ('nm3','male','1000');
insert into test values ('nm4','unknown',NULL);
I am new to PHP, just learning.
I've a sample data of my table. While showing data in front, for gender I've to show
only the first character i.e. m/f/u and
for salary I've to sum the total amount from front i.e
by using PHP.
also in my table salary is in varchar would I've to parse it as number?
<pre lang="xml"><?php
include('conn.php');
$result =mysql_query("select * from test")
or die(mysql_error());
echo "<table cellpadding = '10'>";
echo "<tr>
<th>name:</th>
<th>gender:</th>
<th>total salary:</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo '<td>'.$row['name'].'</td>';
echo '<td>'.$row['gender'].'</td>';
echo '<td>'.$row['salary'].'</td>';
}
?>