voting ballot in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alijen
    New Member
    • Sep 2011
    • 1

    voting ballot in php

    Hello!

    I don't know how to get the data in the database that shows in the radio button. This is my code:

    Code:
    <?php
    $server = 'localhost';
    $user = 'root';
    $password = '';
    $database = 'ssgelectionsystem';
    $con = mysql_connect ($server,$user,$password);
    $db = mysql_select_db($database);
     if (!$db || !$con)
     {
         die ('<h3>SERVER DOWN BE BACK LATER</h3>');
     }
     else
     {
        if (isset($_POST['save'])) {
    
        $selected_radio = $_POST['position'];
    
        if ($selected_radio == 'name') {
        $name_status = 'checked';
       }
        else if ($selected_radio == 'name'){
        $name_status = 'checked';
       }
     }
     } 
     
    ?>
    <form name ="form1" method ="Post" action="radioButton.php">
        <table border="0" align ="">
        <td>President</td>   
        </table>
        
             <td><input type="radio" name="name" size="30"></td>  
             <?php
             $query="SELECT* FROM can_reg";
             $result=  mysql_query($query);
             while($record=  mysql_fetch_array($result))
             {
                 echo"<option>{$record['name']}</option>";
                
             }
             ?>
           
        <tr>
            <td></td>
             <td><input type="submit" name="save" value="SUBMIT"></td>
        </tr>
    </form>
    ------------------------------------------------------
    the result is 1 radio button in 2 names....
    Last edited by Niheel; Sep 10 '11, 09:17 AM.
Working...