0

I am on the process of modifying old code. I want to have set of input fields as rows in a table with Update button along with them. Below code is included in seperate ajax_edit_designation.php page which is being called by the edit_designation page. When the update is selected it should enter the new value to the database. The script required for it is written in the edit_designation.php page.

I would like to know whether what I am doing is correct or wrong. Because for some reason it doesn't carryout required action when the 'Update' button is selected. In the browser console it doesn't throw any exceptions either. What am I doing wrong?

Is it something that happen due to some kind of version issue? Or am I really doing something wrong?

echo "<table>";
while($row_tay = mysql_fetch_array($result_tay)){
    $temp++;
    $designation    = $row_tay['designation'];
    $designationID  = $row_tay['designationID'];

    echo "<tr ";
        if($temp%2 == 1)
            {
            echo " bgcolor =\"#F3F3F3\" ";
            }
        else
            {
            echo " bgcolor =\"#DBDBDB\" ";
        }
    echo " >";      
        echo "<form id=\"myform".$designationID."\" method=\"post\">";
            echo "<td class=\"bodytext\">";                                                         
                echo "<input type=\"text\" id=\"designation\"  size=\"50\" value=\"".htmlentities($designation)."\" name=\"designation\" />";                                   
            echo "</td>";
            echo "<td width=\"120\" align=\"center\">";
                echo "<input name=\"addcat\" id=\"addcat\" type=\"submit\" value=\"Update\" class=\"Submit_Button_long\">";
                echo "<input type=\"hidden\"  name=\"designationID\" value=\"".$designationID."\">";                                
            echo "</td>";   
        echo "</form>";
    echo "</tr>";
    }
echo "</table>";

Because, same thing happened to me in another page also, where I added seperate form tags as above. In that case, previously it had given all the Update buttons under same tag. When I remove that earlier form tag and add only the new tags as above, they didn't work as now. But if I add that previously available tag, by wrapping all those forms created with the table, Update buttons worked. What could be the reason. Please help?

udani
  • 1,243
  • 2
  • 11
  • 33
  • Have your head about heredoc? will make your life simpler and your less prone to errors code - http://php.net/manual/en/language.types.string.php – Pedro Lobito May 02 '16 at 09:50
  • Please dont use [the `mysql_` database extension](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php), it is deprecated (gone for ever in PHP7) Specially if you are just learning PHP, spend your energies learning the `PDO` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly May 02 '16 at 10:04
  • Thank you about heredoc thing, I didn't knew about it before. Looks like it makes life easier. But do you say that escaping part has prevented the update button from working? – udani May 02 '16 at 10:04
  • I am trying to modify few years old code which has been developed by number of people under different php versions. – udani May 02 '16 at 10:08
  • Does it cause this script to run again OR. Does it not rerun this script – RiggsFolly May 02 '16 at 10:09
  • What do you mean? Are you asking me to change the double quotes to single quotes, where I have provided values to html properties? – udani May 02 '16 at 10:13
  • What `DOCTYPE` are you using – RiggsFolly May 02 '16 at 10:22
  • Well I am unable to find, because it doesn't mention anything about DOCTYPE. – udani May 02 '16 at 10:30

0 Answers0