0

I am trying to display multiple columns with multiple rows from a database. It works to display one row, but when I put in the second one it just displays two of the same. Like an echo. How do I get it to display the two different numbers?

  $result = mysql_query("SELECT plea, COUNT(plea) as cee FROM tee WHERE section='d' GROUP BY     
plea"      , $c) or die("two");  

$number=mysql_num_rows($result);    
  if($number>0)   
        {
            $i=0;
        while($row_result = mysql_fetch_array($result))
            {
        $plea.$i = $row_result['plea'];
        $cee.$i = $row_result['cee'];
        echo $plea.$i."&nbsp;&nbsp;&nbsp;&nbsp;".$cee.$i."<br><br>";

            $i++;
           }

    }
3
  • Do you get the same result when running the query in mysql/phpmyadmin? Commented Feb 26, 2014 at 19:07
  • Did you check your sql in something like mysql workbench to ensure your call is not getting "mirrored" column values? Commented Feb 26, 2014 at 19:09
  • No, it works perfectly in the admin, well, thats obviously not using the while stuff, just the query works perfectly Commented Feb 26, 2014 at 19:10

1 Answer 1

1

This is VERY strange code:

 $plea.$i = $row_result['plea'];

and NOT doing what you want. It's parsed as:

 $plea . ($i = $row_result['plea']);

and boils down to $i getting your value from the query, and then being further executed down to just

 TRUE

without EVER modifying the value in $plea. You probably want an array:

$plea[$i] = $row_result['plea'];
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.