PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > Problem with two recordset
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problem with two recordset

Réponse
 
LinkBack Outils de la discussion
Vieux 25/09/2007, 11h53   #1
nervino
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problem with two recordset

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;

}
  Réponse avec citation
Vieux 25/09/2007, 14h02   #2
C.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with two recordset

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.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 21h23.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09005 seconds with 10 queries