dimanche 18 octobre 2015

I want to be able to select from checkboxes 5 factors and then put the ranking 1 to 5 next to the factors

the form to display checkboxes to select five factors and input box for the user to type-in the value from 1 to 5.

the form

<tr>    
<td>Factor Affected</td>
<td>
<table>
<?php
while ($row = mysql_fetch_array($querydata)) 
{ ?>
<tr>
<td><input type="checkbox" name="factorid[]" value="<?php echo $row['factorid']; ?>" >
<?php echo $row['factorcategory'];?></td>
<td><input type="number" step="any" min="1" max="5" name="orderno[]"></td>
</tr>
<?php
} ?>
</table>
</td>
</tr>

AND the php that I have written:

    if (isset($_POST['factorid']) && isset($_POST['orderno']))
    {
             foreach ($_POST['factorid'] as $factorid)
            {

                    echo $factorid.$orderno; ?> <br /> 

                    <?php
                    if (($factorid=="") || ($orderno==""))
                    {
                        echo "<p align='center' align='justify'>"."You must select 5 factors!"."</p>";
                    } 
                    else                
                    {
                            $SQL44 = "INSERT INTO $tablename7 (TRID, factorid, orderno) VALUES (LAST_INSERT_ID(), '$_POST[factorid]', '$_POST[orderno]')";
                            $querydata44 = mysql_query($SQL44);

                            if(!$querydata44)
                            {
                                    echo "Insert Top Factor Info Failed".mysql_error();
                                    exit();
                            }
                     }

            }
    }

Thanks in advance. YES, I am still using the old php. This is to code a prototype, I don't know how to code in php mysql-li.

Cheers!




Aucun commentaire:

Enregistrer un commentaire