samedi 27 décembre 2014

parameter is lost while looping with php

i still not understand, with this simple logic but still make me not get the parameters declared variable name $form then, the result of $form is



<input type="checkbox" id="ID_0">
<input type="checkbox" id="ID_0">
<input type="checkbox" id="ID_0">
<input type="checkbox" id="ID_0">


not as expected, like this



<input type="checkbox" id="ID_0">
<input type="checkbox" id="ID_1">
<input type="checkbox" id="ID_2">
<input type="checkbox" id="ID_3">


my simple code is like this



$data = array(); //contains example 9 data
$total_data = count($data);

$sql = "SELECT name from table";
$result = $_CONN->Execute($sql);
$total = $result->RecordCount();

if($total > 0){
for($i=0;$i<$total_data;$i++){
$dataID = "ID_".$i;
while (!$result->EOF){
$form .= '<input type="checkbox" id="'.$dataID.'" name="checkData[]" value="'.$result->fields["name"].'">'.$result->fields["name"];
$result->MoveNext();
}
}
}else{
echo "No data from Table";
}




Aucun commentaire:

Enregistrer un commentaire