0

i don't know what is the expected problem in fetching rows :\ why the result look like this ?

$result=mysql_query($query);
            $tbl.="<table id=tblsearch align =center border=0 > 
            <tr bgcolor=gray>";

            $RowNum =mysql_num_fields($result);
            //name of field :) .... 
            for($col=0;$col<$RowNum;$col++)

            $tbl.='\n <th font color=white>'.
             mysql_field_name($result, $col).'</font></th>';
            //update/delete OK 
            $tbl.='\n </tr>';
            $rownow=1;
            while ($row =mysql_fetch_row($result)) { //fetch_row
                $tbl.'<tr onmousemove=\"HighLightRow($rownow)\" bgcolor=#eehh99';
                if ($rownow%2==0)
                $tbl.="#669999>";
                else 
                    $tbl.="#66CC99>";
                    $rownow++;
            for($col=0;$col<$RowNum;$col++)
            $tbl.='\n  <td> $row[$col] </td>';
            $tbl.='</tr>';
            }//while

            if(mysql_errno()==0)

            return $tbl.'</table>';
         else 
             return "error".mysql_error();

           }//function

enter image description here

please don't tell me to use mysqli instead of mysql -_- i will in future i'm a student and To become a master first i must learn to be a student.

2
  • 2
    I don't understand. Why do you need to be a master to use the correct function? Commented Aug 8, 2014 at 23:06
  • i will when i study that functions Commented Aug 8, 2014 at 23:11

1 Answer 1

2

Variables are only expanded inside double quotes, not single quotes. So change:

$tbl.'<tr onmousemove=\"HighLightRow($rownow)\" bgcolor=#eehh99';

to:

$tbl."<tr onmousemove=\"HighLightRow($rownow)\" bgcolor=#eehh99";

and:

$tbl.='\n  <td> $row[$col] </td>';

to:

$tbl.="\n  <td> $row[$col] </td>";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.