Jump to content

How to tell whats changed.


mike12255

Recommended Posts

Ive created a process which automatically creates a form for all of the "courses" that are listed in a database. This table shows the name, the course code, the current program the course is under and an option to delete the course. I have created a drop down menu for the user to select any of the current programs to switch the course into. My problem is I have X amount of select fields and radio buttons and I dont know how to tell which one has been changed below is my code, appreciate the help!:

 

 

        case "ep":
        
        if (isset ($_GET['id'])){
            $id = $_GET['id'];
                    echo "Below lists all of the current courses under this program. Once you have made all of the changes click the submit button at the bottom of the page. <br><br><br>";
                    $query = "SELECT * FROM courses WHERE cid = $id";
                    $result = mysql_query($query) or die (mysql_error());
                    echo "<form action=\"course_process.php\" method=\"post\">";
                    echo "<table><tr><td><strong>Course Name</strong></td><td><strong>Course Code</strong></td><td><strong>Change Course Program</strong></td><td><strong>Delete</strong></td></tr>";
                    $i = 0;
                    
                    while ($row = mysql_fetch_assoc($result)){
                        $r = $row['id'];
                        $query2 = "SELECT * from catagories";
                        $result2 = mysql_query($query2) or die (mysql_error());
                        echo "<tr><td> ". $row['name']. " </td><td> ".$row['code']." </td><td><select name=\"".$row['id']."\">";
                        
                        while ($row2 = mysql_fetch_assoc($result2)){
                        
                        echo "<option value=".$row2['id'].">".$row2['name']. "</option>";
                            }
                            
                             echo "</select></td><td><input name=\"".$row['id']."\" type=\"radio\" value=\"Click to delete\" /></td></tr>";
                    }
                    echo "<tr><td></td><td></td><td></td><td><input name=\"submit\" type=\"submit\" value=\"Commit Changes\" /> </td></tr></table></form>";
                    
                    
                }else{
                    echo "Invalid action request. ERROR CODE 1";
                    
                }
                
        break;

Link to comment
Share on other sites

If you let the default value for the select box be blank, I don't think that will come through on the POST values.  I could be wrong about that, someone else could clarify that.

Mike

 

I am pretty sure if you leave a value empty the $_POST var will still be set.

edit yep vars are set: for illustration purposes:

?>
        <form action="" method="post">
            <input type="text" name="bla" />
            <input type="text" name="bla2" />
            <input type="text" name="bla3" />
            <input type="text" name="bla4" />
            <input type="submit" name="submit" value="submit" />
        </form>
        
        <?php
        print_r($_POST); // oprints: Array ( [bla] => [bla2] => [bla3] => [bla4] => [submit] => submit ) 
        ?>

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.