Click here to Skip to main content
15,919,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The logical error here is every time I edit the subject code nothing happens.

here's my code:

PHP
if(isset($_POST['update'])){

    $sub_code=$_POST['sub_code_txt'];
    $semester=$_POST['semestertxt'];
    $subject_name=$_POST['subtxt'];
    $units=$_POST['units_txt'];
    $note=$_POST['notetxt'];

    $sql_update=mysql_query("UPDATE subjects SET

                            sub_code='$sub_code',//this is the problem, cannot be updated
                            semester='$semester',
                            subject_name='$subject_name',
                            units='$units',
                            note='$note'

                        WHERE sub_code='$sub_code'
                    ");

<tr>
     <td>Subject Code</td>
        <td>
            <input type="text" name="sub_code_txt" id="textbox" value="<?php echo $rs_upd['sub_code'];?>"  />
         </td>
</tr>
Posted
Comments
Mohibur Rashid 23-Sep-15 20:21pm    
Yeah, the query is written that way.
you want to update sub_code to $sub_code and it would only happen only if the sub_code is already equal to $sub_code. in other word:
"UPDATE subject SET sub_code='sub_01' WHERE sub_code='sub_01';", will it change anything?

Also take a look at sql injection

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900