I am trying to execute this query but i got error " Undefined index:
lname".I want to count row from one column(fname) from table a and
select column(lname) from other table b. so please help me.
$result = mysql_query("SELECT COUNT(fname),lname FROM a,b");
while ($row = mysql_fetch_array($result))
{
echo "
";echo $row['lname'];
echo "
";echo "
";echo $row['COUNT(fname)'];
echo "
";}
解决方案
You need to use an alias. Use this:
$result = mysql_query("SELECT COUNT(fname) AS countfname,lname FROM a,b");
while ($row = mysql_fetch_array($result))
{
echo "
";echo $row['lname'];
echo "
";echo "
";echo $row['countfname'];
echo "
";}