You are here: Re: Problem with two recordset « PHP Language « IT news, forums, messages
Re: Problem with two recordset

Posted by C. on 09/25/07 12:02

On 25 Sep, 10:53, nervino <m...@falsa.com> wrote:
> 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;
>
> }

FFS use a join in one recordset!

C.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация