Jump to content
Larry Ullman's Book Forums

Recommended Posts

I give up!!

 

What is wrong with this code?

 

            while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
                echo "<tr class=\"data\" align=\"center\" width=\"100%\">
                    <form action=\"edit_other_medical_problem.php\" method=\"POST\">
                        <td align=\"center\">{$row['AssessmentDate']}</td>
                          <td align=\"center\">{$row['MedicalProblem']}</td>
                          <td align=\"center\">{$row['TreatmentPlan']}</td>
                          <td align=\"center\">{$row['OtherDetails']}</td>
                        <td align=\"center\">
                            <input type=\"submit\" name=\"submit\" value=\"Edit\">
                              <input type=\"hidden\" name=\"MedicalProblemID\" value=\"{$row['ID']}\">   
                        </td>
                    </form>";
                    echo "<form action=\"delete_other_medical_problem.php\" method=\"POST\">
                            <td align=\"center\">
                                      <input type=\"submit\" name=\"submit\" value=\"Delete\">
                                      <input type=\"hidden\" name=\"MedicalProblemID\" value=\"{$row['ID']}\">
                            </td>
                          </form>";  
                    echo "</tr>";
            }
 

 

The "Delete" button works beautifully but the "Edit" button remains on this page instead of opening "edit_other_medical_problem.php".

 

I cannot see the difference.

Share this post


Link to post
Share on other sites

Hmmm... at first glance, it looks okay.

Do you get any errors or anything, or does absolutely nothing happen when you click the button?

Could you please provide a sample of the HTML that is created by this PHP?

Thanks.

Share this post


Link to post
Share on other sites

Are you sure about that, margaux?

I'm not saying you're wrong, but that seems weird.

I created the following quick scripts to test things out, and both forms seem to submit fine:

 

index.php

<?php
  
  echo '<form action="form1.php" method="post">
  
  <input type="hidden" name="a" value="a">
  
  <input type="submit" name="submit" value="Submit">
  
  </form>
  
  <form action="form2.php" method="post">
  
  <input type="hidden" name="b" value="b">
  
  <input type="submit" name="submit" value="Submit">
  
  </form>';

Share this post


Link to post
Share on other sites

And the code for form1.php and form2.php is the same. The code is the following:

 
form1.php/form2.php
<?php
  
  print_r($_POST);
 
By placing the three above files in the same folder and running index.php, both forms seem to properly submit to the intended scripts.
Am I missing something?
 
Edit: I had to make two posts, because for whatever reason, my post kept getting cut off if I only did one.

Share this post


Link to post
Share on other sites

Big apologies, I read this far too quickly (and too early) on the train and was thinking this was two submit buttons. Code originally posted looks okay.

Share this post


Link to post
Share on other sites

Thanks for your input on this problem.

 It turned out that I had an error in the code where it had to decide whether Submitted was true or not.

The program thought that Submitted was TRUE and just saved the variables back to the database and returned to the calling page.

 

Thanks again.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...