Chaning code from radio button to frop down menu

Discussion in 'PHP' started by grusomhat, Apr 10, 2007.

  1. #1
    Hello All programers here. Hopefully someone can help me

    I am using the free sms script as posted in another thread. I have added more providers to the database which has cause the display to mess up on the index.
    What I am wanting to do is switch it from radio buttons to a dropdown menu.

    Here's the code for the buttons

    function get_providers(){
    	echo"<table width='100%'><tr><td width=200' align='left'>";
    	$p = 0;
    	$query = mysql_query("SELECT * FROM `providers` ORDER BY `name` DESC");
    	while($fetch = mysql_fetch_array($query)){
    		$p++;
    		// Limit 3 per row
    		if($p % 7 == 0){
    			$new_line = "</td><td width='200' align='left'>";
    		}else{
    			$new_line = "";
    		}
    		echo"<input type='radio' value='$fetch[address]' class='radiok' name='prov'> $fetch[name]<br />$new_line";
    	}
    	echo"</td></tr></table>";
    }
    Code (markup):

     
    grusomhat, Apr 10, 2007 IP
  2. briansol

    briansol Well-Known Member

    Messages:
    221
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    #2
    
    function get_providers(){
    	echo"<table width='100%'><tr><td width=200' align='left'>";
    echo "<select name=\"prov\">";
    	$query = mysql_query("SELECT * FROM `providers` ORDER BY `name` DESC");
    	while($fetch = mysql_fetch_array($query)){		
    		echo"<option value='$fetch[address]'> $fetch[name]</option>\r\n";
    	}
    echo "</select>";
    	echo"</td></tr></table>";
    }
    
    Code (markup):
     
    briansol, Apr 11, 2007 IP
  3. grusomhat

    grusomhat Peon

    Messages:
    277
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I bet you to it and came to post the code I worked out and saw someone had replied. Thanks for your response. I think your code is the same as mine

    function get_providers(){
    	echo"<table width='100%'><tr><td width=200' align='left'>";
    	echo"<select name='prov' >";
    	$p = 0;
    	$query = mysql_query("SELECT * FROM `providers` ORDER BY `name` ASC");
    	while($fetch = mysql_fetch_array($query)){
    		echo"<option value='$fetch[address]'> $fetch[name]</option>";
    		}
    	echo"</select>";
    	echo"</td></tr></table>";
    }
    Code (markup):
     
    grusomhat, Apr 11, 2007 IP