We help IT Professionals succeed at work.

PHP to update MYSQL query

bcmeyer1983 asked
Last Modified: 2013-12-12
ok so i have a few lines of php code that echos a mysql query:


<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


<form action="approve.php" method="POST">
      <table border="1" width="19%" id="table1" style="border-width: 0px">
                  <td width="104" style="border-style: none; border-width: medium">
                  <font size="2">Approval</font></td>
                  <td width="58" style="border-style: none; border-width: medium">
                  <input type="text" name="approval" size="10"></td>
                  <td style="border-style: none; border-width: medium"><font size="1">
                  <td width="104" style="border-style: none; border-width: medium">&nbsp;</td>
                  <td width="58" style="border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium">
                  <p align="center"><input type="submit" value="Submit" name="B1"></td>
                  <td style="border-style: none; border-width: medium">&nbsp;</td>





$mysqli = mysql_connect($hostname,$username,$password);

if (mysql_errno()) {
      printf("Connect failed: %s\n", mysql_errno());
} else {
      $sql = "SELECT * FROM table WHERE approval = '{$_POST['approval']}'";
      $res = mysql_query($sql, $mysqli);
            if ($res) {
                  while ($newArray = mysql_fetch_array($res, MYSQL_ASSOC)) {
                                               $amount1 = $newArray['amount1'];
                                    $approval = $newArray['approval];
                                    echo "".$amount1."";
                                    echo "<br/>";
                                    echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\">\n";
                                    echo "<tr><td>Do you wish to approve:";  <-----------------would like a checkbox field here to replace current record being displayed in: approval - to a value of 1 when the form is submitted.  
                  } else {
                        printf("did not work: %s\n", mysql_error($mysqli));

question is within code:
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


basically i am just in an effort to pull information from mysql rows, display them, then be able to update them. above i am currently just echoing info in a row


i am only updating just 1 item from the row


another thought is that there could be up to 20 items that may need the checkbox. all depending on which ones have not been updated.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.