Hello everyone,
I used session and the id of the selected checkbox are passed to another page currently.
now I do another query based on the ID of the selected checkbox.
I want to display the fields from the selected result in columns like this
http://www.bluenile.co.uk/diamond_co...OMPARISON_STEP

I did this

<?
	foreach($acb as $key => $value)
	    {
	    echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />';
		//print out the values
	 
			$query = "SELECT * from lesson WHERE lessonID ='".$value."'" ;
			$result = mysql_query( $query, $con); 
	        $result_array = mysql_fetch_array($result);
	//echo $query;
	// for each pice of info saved in array, display it to users
	echo '<table>';
	foreach($result_array as $key => $value)
	//while($row = mysql_fetch_array($result_array))
	{
			if (!is_int($key))
			{
	 
		echo '<tr><td>Lesson ID</td><td>'.$result_array['lessonID'].'</td></tr>';
		echo '<tr><td>Year</td><td>'.$result_array['year'].'</td></tr>';
		echo '<tr><td>Subject</td><td>'.$result_array['subject'].'</td></tr>';
		echo '<tr><td>Learning Area</td><td>'.$result_array['learningArea'].'</td></tr>';
		echo '<tr><td>Topic</td><td>'.$result_array['topic'].'</td></tr>';
		echo '<tr><td>Learning Outcome</td><td>'.$result_array['LO'].'</td></tr>';
			}
	}
	echo '</table>';
      }
	?>

the result returned like this

Lesson ID 52
Year 4
Subject ICT
Learning Area Computer Systems
Topic Hardware
Learning Outcome Storage
Lesson ID 52
Year 4
Subject ICT
Learning Area Computer Systems
Topic Hardware
Learning Outcome Storage
Lesson ID 52
Year 4
Subject ICT
Learning Area Computer Systems
Topic Hardware
Learning Outcome Storage

it is loops for several times before showing the next records from the selected checkbox (also several times).
I want to have them displayed in columns like the example above.
can anyone help?
thankyou

It displayed exactly as you defined it. If you want the data in columns, then don't use a <tr><td> before every field, just use <td>. Every time you echo a <tr> you get a new line.

Member Avatar for rajarajan2017
if (mysql_num_rows($result) > 0) { 
    // yes 
    // print them one after another 
    echo "<table cellpadding=10 border=1>"; 
    while($row = mysql_fetch_row($result)) { 
        echo "<tr>"; 
        echo "<td>".$row[0]."</td>"; 
        echo "<td>" . $row[1]."</td>"; 
        echo "<td>".$row[2]."</td>"; 
        echo "</tr>"; 
    } 
    echo "</table>"; 
}

Dont assign everytime the headings

thank you rajarajan,
i changed the code according to your suggestion,
but there is no data displayed now.
if two checkboxes is selected, there will be three columns
(1st the field, 2nd -the records of the 1st checkbox, 3rd-the records of the 2st checkbox.
any suggestions?
thank you

Member Avatar for rajarajan2017

check first the above code display your records retrieved from database

Result is returned as in my previous posting.
the thing is just to display the result in comparable table like here http://www.bluenile.co.uk/diamond_co...OMPARISON_STEP

now the fields name is displayed in the left column, it 's right but it's looping so many times. I just want to make it once.
the results are they but they looping together with the fields name. I want the result to be presented side by side.
Any suggestions?
thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.