Jump to content

Loop results to compare data


Julian

Recommended Posts

Hi guys.

 

I have almost everything done with this script.  What it does is show me checkboxes with text.  I achieved this with the following code:

<?php

//get the number of rows in our result so we can use it in a for loop
$numrows = (mysql_num_rows ($es));

// loop to create rows
if($numrows >0){
echo "<table width ='100%' border = '0' cellspacing = '5' cellpadding = '0'>";
// loop to create columns
$position = 1;
	while ($work = mysql_fetch_array($es)){
	  if($position == 1){echo "<tr>";}
	  echo "<td width='18' valign='top'><input type='checkbox' id='espe' name='id_especialidad[]' value=''";
	  if (!(strcmp($work['id_especialidad'],$row_espe['id_especialidad']))) {echo "checked";} //Loop here
	  echo "></td>";
	  echo "<td class='class10'>" . $work['especialidad'] . "</td> ";
	  if($position == 4){ echo "</tr> "; $position = 1;}else{ $position++;}
	}

$end = "";
 if($position != 1){
  for($z=(4-$position); $z>0 ; $z--){
  $end .= "<td></td>";
  }
  $end .= "</tr>";
 }
echo $end."</table> ";
}
						?>

 

I need to compare to tables to put "checked" where the user already checked the box. But I can show only the first record on the database checked.  I think I need to loop to compare buy don't know how.  Any help will be appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/162577-loop-results-to-compare-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.