Posted by nervino on 09/25/07 09:53
I am trying to print "selected" when an id of the first recordset is
also present in the second recordset.
I did the code below but it only print out "selected" one time, and I'm
shure there are two id in the second recordset identical to two id of
the first.
What do I mistake?
(I hope my english to be understandable)
Thank you
My code:
$query_cat = "SELECT * FROM cat_documenti ORDER BY categoria ASC";
$result_query_cat=mysql_query($query_cat)
or die('Query failed. ' . mysql_error());
$query_cat_sel = "SELECT id_categoria_doc FROM link_cat_doc WHERE
id_documento =".$id_documento;
$result_query_cat_sel=mysql_query($query_cat_sel)
or die('Query failed. ' . mysql_error());
$dati_recordset = mysql_fetch_array($result_query_news);
$dati_recordset_cat_sel = mysql_fetch_array($result_query_cat_sel);
while ($dati_recordset_cat = mysql_fetch_array($result_query_cat)) {
$id_categoria_doc=$dati_recordset_cat['id_categoria_doc'];
$categoria=$dati_recordset_cat['categoria'];
while ($dati_recordset_cat_sel = mysql_fetch_row($result_query_cat_sel)) {
$id = $dati_recordset_cat_sel["id_categoria_doc"];
if (in_array($id_categoria_doc, $dati_recordset_cat_sel)) {
echo " selected=\"selected\"";
}
}
print $categoria;
}
[Back to original message]
|