Jump to content

Select make checkbox


Readme

Recommended Posts

This functions used select data but I want use <input type="checkbox"/>

Please help to modify.

//----------get country via select option----------
function get_country()
{
    
    $sql = "SELECT id,country FROM countries ORDER BY id ASC";
    $res = mysql_query($sql);
        
    echo "<select id=\"country\" class=\"searchbox\" name=\"country\">";
        echo "<option value=\"\">Select One</option>";
        while ($row = mysql_fetch_assoc($res)){
            echo "<option value=\"".$row['country']."\">".$row['country']."</option>";
            }
    echo "</select>";
}

//----------get countries via select option from users----------
function get_select_countries($id)
{
    $id = secureInput($id);
    
    $sql = "SELECT country FROM countries ORDER BY country ASC";
    $res = mysql_query($sql);
        
    $sql1 = "SELECT country FROM users WHERE id='".$id."'";
    $res1 = mysql_query($sql1);
    $row1 = mysql_fetch_assoc($res1);
    
    if($row1){
        echo "<select name=\"country\">";
        echo "<option selected=".$row1['country']." value=\"".$row1['country']."\">".$row1['country']."</option>";
        while ($row = mysql_fetch_assoc($res)){
            echo "<option value=\"".$row['country']."\">".$row['country']."</option>";
            }
        echo "</select>";
        } else {
            echo "<select name=\"country\">";
            while ($row = mysql_fetch_assoc($res)){
                echo "<option value=\"".$row['country']."\">".$row['country']."</option>";
            }
            echo "</select>";
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.