PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 16th, 2004, 01:54 PM
gurzonek gurzonek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 gurzonek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question comparing the array results of two queries

Hi guys,

I´m trying to find some help to this problem

I have two queries the first one ($query_u) gets all the languages stored in a batabase table called language.

The second ($query_u2) gets all the selected languages that are stored to a table called language_level.

So I want to print a form by which the user can edit his previously inserted language values. There are 6 lists of languages and all have different names (language_1, language_2...language_6). So what I want is that if the user has selected 3 languages of the 6, I want to pront the first 3 lists with the selected languages listed as a "SELECTED" option.

Here is the code I use:


PHP Code:
for($i 1$i <= 6$i++)
  {
   
$query_u "SELECT id, name FROM language ORDER BY name ASC";
   
$result_u mysql_query($query_u) or die ("Error in query: $query_u. " .mysql_error());

   
$query_u2 "SELECT language_id FROM language_level WHERE user_id ='$row_b->id'";
   
$result_u2 mysql_query($query_u2) or die ("Error in query: $query_u2. " .mysql_error());     
   
   
$selectoptions "";
   while (
$row_u mysql_fetch_object($result_u))
   { 
      
$selectoptions .= "<option value=\"$row_u->id\" ";
      while(
$selection mysql_fetch_object($result_u2))
      { 
      if(
$selection == "$row_u->id")
      { 
         
$selectoptions .= "selected"
      }
      } 
      
$selectoptions .=">$row_u->name</option>\n"
   }



With this code I only getting one of the 3 selected languages, which is actually the first in the language_level table. I see that the $selection variable is only containing one of the values, and it has to contain 3 actually.

What is wrong in the code? How can I fix it?

Reply With Quote
  #2  
Old September 17th, 2004, 12:21 AM
gurzonek gurzonek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 gurzonek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SOME HELP HERE PLEASE??

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > comparing the array results of two queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway