Bhupender rathor
Bhupender rathor

Reputation: 34

For the Data Update

Hello I am begginner in php. I create a simple Dyanamic site. first I fetch all information from database.and Take for the Edit formate all is going correct but I have problem in quantity input. when the i input the next value inside so that before all entries automatic changeed.....how????

Update formate Code....

<form action="edit.php" method="post">

    <tr>
        <td style="font-size:24px">Name &nbsp;</td>
        <td style="font-size:24px"><?php echo $data['name']; ?></td><br />
    <tr>
        <td style="font-size:24px">Project Name &nbsp;</td>
        <td style="font-size:24px"><?php echo $data['project_name']; ?> </td> <br />
    </tr>
    <tr>
        <td style="font-size:24px">cost &nbsp;</td>
        <td style="font-size:24px"><?php echo $data['cost']; ?> </td><br />
    </tr>
    <div>
        <span><label>Payment 1 </label></span>
        <span><input type="text" class="textbox" value="<?php echo $data['payment_1']; ?>" name="payment_1"></span>
    </div>

    <div>
        <span><label>Payment 2</label></span>
        <span><input type="text" class="textbox" value="<?php echo $data['payment_2']; ?>" name="payment_2"></span>
    </div>
    <div>
        <span><label>Payment 3</label></span>
        <span><input type="text" class="textbox" value="<?php echo $data['payment_3']; ?>" name="payment_3"></span>
    </div>
    <div>
        <span><label>Payment 4</label></span>
        <span><input type="text" class="textbox" value="<?php echo $data['payment_4']; ?>" name="payment_4"></span>
    </div>
    <div>
        <span><label>Payment 5</label></span>
        <span><input type="text" class="textbox" value="<?php echo $data['payment_5']; ?>" name="payment_5"></span>
    </div>                          
   <div>
        <span><button type="submit" class="submit_btn" href="">Submit</button></span>
  </div>
</form>

Upvotes: 0

Views: 38

Answers (2)

@bhupender what is your main error? as you stated in your comment your mysql update code. i didnt see any WHERE Clause.

---Answer---

use mysqli instead of mysql because it's already deprecated.

using UPDATE you should'nt forget the WHERE Clause. then do the escaping strings with prepare statement.

$query=$mysqli_prepare($mysql);
$query->execute();

or better see this QUESTION

Upvotes: 0

Sougata Bose
Sougata Bose

Reputation: 31749

There should be a Where clause. With out the clause it is updating all the rows.

$mysql="UPDATE client SET payment_1='$payment_1', payment_2='$payment_2', payment_3='$payment_3', payment_4='$payment_4', payment_5='$payment_5' where ...";

Please do the escaping atleast.

Upvotes: 1

Related Questions