Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
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
?
213 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
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

580 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