Server Administration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesServer Administration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old July 28th, 2006, 12:01 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
drop down list help needed

Ok i've been having trouble with this for a while so i hope someone here can help. I have a drop down list from which you can select a state and the save it. It then get's inputed in a mysql database. And when i go back to the page the option i selected before remains selected on the drop down list and it all works ok. However now i would need to modify the list so that instead of AZ for Arizona, when i select Arizona i want <a href="http://www.google.com>Google</a> inputed in the database. This is just an example. Now how would i modify the drop down box to accomodate this. Here is the code:

Code:
<?php

// THIS IS YOUR ARRAY
$a[0][0] = "AL";
$a[0][1] = "Alabama";
$a[1][0] = "AK";
$a[1][1] = "Alaska";
$a[2][0] = "AZ";
$a[2][1] = "Arizona";
$a[3][0] = "AS";
$a[3][1] = "Arkansas";
$a[4][0] = "CA";
$a[4][1] = "California";

echo "<select name="medal_image">";//uncomment this line when you want it to work
foreach ($a as $v1)
{

echo "<pre>a = ",var_dump($a),"</pre><br>n";
echo "<pre>v1 = ",var_dump($v1),"</pre><br>n";

//next two lines were used for testing when the second loop was uncommented
echo "v1 = ",var_dump($v1),"<br>n";
echo "v2 = ",var_dump($v2),"<br>n";
echo "<pre>$medal_image = ",var_dump($medal_image),"</pre><br>n";
if ($v1[0] == $medal_image) //$state holds a two-letter acronym (i.e: "AL")
//maybe after you add some more code that will be true
//right now, $state is always NULL
{
$sel_text = " selected ";
}
else
{
$sel_text = " ";
}
echo "<option value=$v1[0]".$sel_text.">".$v1[1]."</option>";


}
echo "</select>";//uncomment this line when you want it to work
?>

Reply With Quote
  #2  
Old August 2nd, 2006, 09:41 AM
speedfight speedfight is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Eindhoven, NB, Netherlands
Posts: 13 speedfight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: drop down list help needed

php Code:
Original - php Code
  1. <?php
  2.  
  3. // THIS IS YOUR ARRAY
  4. $a[0] = Array("AL", "Alabama");
  5. $a[1] = Array("AK", "Alaska");
  6. $a[2] = Array("AZ", "Arizona");
  7. $a[3] = Array("AS" ,"Arkansas");
  8. $a[4] = Array("CA" ,"California");
  9.  
  10. /* */
  11. $medal_image = isset($_GET['medal_image']) ? $_GET['medal_image'] : 'AZ';
  12. /* */
  13.  
  14. echo "<select name="medal_image">n"; //uncomment this line when you want it to work
  15. foreach ( $a as $v )
  16. {
  17.     list($short, $long) = $v;
  18.  
  19.     if ( $short == $medal_image)
  20. //$state holds a two-letter acronym (i.e: "AL")
  21. //maybe after you add some more code that will be true
  22. //right now, $state is always NULL
  23.     {
  24.         $sel_text = ' selected="selected"';
  25.     }
  26.     else
  27.     {
  28.         $sel_text = '';
  29.     }
  30.     echo "<option value="$short"".$sel_text.">".$long."</option>n";
  31. }
  32. echo "</select>n"; //uncomment this line when you want it to work
  33.  
  34. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesServer Administration > drop down list help needed


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 3 hosted by Hostway