?
Solved

How do I pass two different arrays of variable at the same time on the same SELECT drop down.[Please look my code]

Posted on 2005-03-02
2
Medium Priority
?
211 Views
Last Modified: 2008-03-06
Table: favorits : id, url, title, f_id;//f_id = users.id
      users:   id, password

Case "tools":
      
      if(isset($_REQUEST['uselect']))
       {
           print("<h3>Url Selected</h3>\n");             
                   $ar = $_POST['uselect'];
            print_r($ar);
/*I want to input `url` and `title` in my database, I am only passing `url` via    select [] and accesing it,
# but how do I passs `title` also through same select without using another drop down menu.
#I know you can AGAIN look in to database for` title`, but that is not what I want, since I already have  `title` in my  $result2 array, and on $a and on $d (please look below)*/


      }
      
      $result = @mysql_query(" SELECT url,title FROM favorites where favorites.id ='$k'");//User id
          if (!$result) {
            exit('<p>Error performing query: ' . mysql_error() . '</p>');
      }
      while ($row = mysql_fetch_array($result)) {
           $result1 = array_merge((array)$result1, (array)($row['url']) );
           $result2 = array_merge((array)$result2, (array)($row['title']) );

      }
      $a = array_combine($result2,$result1); ///////// ARRAY $a
      $d = array_map("map_Spanish", $result2 , $result1);// ///////// ARRAY $d

      $num = mysql_numrows($result);
      while($num>0){
         print("<form action=\"webtools.php?section=tools\" method=\"post\"> ");
         $i = 0;
         print( "<SELECT name=\"uselect[]\" SIZE=\"1\">");
                  foreach($a as $key=>$val) {
                        echo "<OPTION VALUE=\"".$val."\">". $key ."</OPTION>\n";            
                              $i++;
                  
                 }
           print( "</SELECT>");
         echo " <br> <br>";
         $num = $num -1;
        }            
      print("<input type=\"submit\">\n");

      print("</form>\n");

break;
0
Comment
Question by:questionphpk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 1500 total points
ID: 13442977
you could concatenate the two using some separator which won't occur in either one, such as | or :, and then use explode() to break it back into pieces.
0
 

Author Comment

by:questionphpk
ID: 13511371
I was thinking of something like this, but you are right it is hard to find a cleverer answer.
Thanks for yours answer.
0

Featured Post

Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question