Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9113245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:55:20+00:00 2026-06-17T03:55:20+00:00

I have a form which populates with data from database, then the user modifies

  • 0

I have a form which populates with data from database, then the user modifies the data or chooses not to modify anything and then simply pushes the submit button to make an UPDATE into the database.My problem is :

  1. i don’t know how to determine which of the fields have had the data modified
  2. how to retrieve the data from the form if the data has been modified
    I use XAMP with PHP 5.3 and HeidiSQL. This is my code

    LOGIN”);
    }
    else
    {
    include(‘../conect.php’);
    //adds an entry if it’s a new field -begin
    if( (isset($_POST)) && (isset($_GET[“nou”])) && (!empty($_POST[‘content’])) &&(!empty($_POST[‘nume’])) && (!empty($_POST[‘cale’])) && (!empty($_POST[‘ordine’])) )
    {
    if( $_POST[‘select’]!=””){
    $nume=stripslashes($_POST[‘nume’]);
    $cale=$_POST[‘cale’];
    $ordine=$_POST[‘ordine’];
    $id=$_POST[‘select’];
    $content = stripslashes($_POST[‘content’]);

        $result=mysql_query("SELECT * FROM categorii_menu WHERE id=$id");
        $data=mysql_fetch_row($result);
        $grad=$data[2];
    
        $result2=mysql_query("SELECT * FROM categorii_menu WHERE grad_categorie=$grad");
        while($data=mysql_fetch_row($result2))
        { 
            if ($ordine==$data[2]) $ok=1;
            else $ok=0; 
        }
        $result3=mysql_query("SELECT * FROM categorii_menu ");
        while($zata=mysql_fetch_row($result3))
        {
            if($nume==$zata[1])
            {
                echo "Deja se foloseste acest nume"; 
                $z=1;
                break;
            }
            else $z=0;
            if(($ok==0)&&($z==0)) 
                mysql_query("INSERT INTO categorii_menu(nume,nr_ordine,grad_categorie,cale,continut) VALUES ('$nume','$ordine','$grad','$cale','$content')");
            else if (($ok==1)&&($z==0))
                echo "Acest nr de ordine este deja luat";   
        }
        else{
            $nume=stripslashes($_POST['nume']);
            $cale=$_POST['cale'];
            $content = stripslashes($_POST['content']);
            $grad=0;
            $ok=0;
            $nr_ordine=$_POST['ordine'];
            $result=mysql_query("SELECT * FROM categorii_menu WHERE grad_categorie=$grad");
            while($data=mysql_fetch_row($result)){
                if($data[2]==$nr_ordine)
                {
                    $ok=1;
                }
            }
            $result3=mysql_query("SELECT * FROM categorii_menu ");
            while($zata=mysql_fetch_row($result3)){
                if($nume==$zata[1]){
                    echo "Deja se foloseste acest nume"; 
                    $z=1;
                    break;
                }
                else $z=0;
            }
            if(($ok==0)&&($z==0))mysql_query("INSERT INTO categorii_menu(nume,nr_ordine,cale,grad_categorie,continut) VALUES ('$nume','$nr_ordine','$cale','$grad','$content')");
            else if(($ok==1)&&($z==0)) 
                echo "Acest nr de ordine este deja luat"; 
            } 
            //adds an entry if it's a new field -end
            //retrieves the modified data from the populated form (but only if all fields are modified :(  , i don't know how to overcome this inconvenience  ) - begin
            else if ( ($_POST) && (isset($_GET["nou"])) ) echo"Nu ati completat toate campurile";
            if( ($_POST) && (isset($_GET["id"])) && (!empty($_POST['content'])) &&(!empty($_POST['nume'])) && (!empty($_POST['cale'])) && (!empty($_POST['ordine'])) ) {            
                if( $_POST['select']!=""){      
                $id=$_GET["id"];
                $nume=$_POST['nume'];
                $cale=$_POST['cale'];
                $ordine=$_POST['ordine'];
                                                                                                                                            $select=$_POST['select'];
                                                                                                                                            $content = stripslashes($_POST['content']); 
                                            $result=mysql_query("SELECT * FROM categorii_menu WHERE id=$select");
                                            $data=mysql_fetch_row($result);
                                            $grad=$data[2];
    
                                            $result2=mysql_query("SELECT * FROM categorii_menu WHERE grad_categorie=$grad");
                                             while($data=mysql_fetch_row($result2))
                                             { if ($ordine==$data[2]) $ok=1; 
                                                else $ok=0; } 
    
                                            $result3=mysql_query("SELECT * FROM categorii_menu ");
                                            while($zata=mysql_fetch_row($result3)){
                                                if($nume==$zata[1]){
                                                   echo "Deja se foloseste acest nume"; 
                                                   $z=1;
                                                   break;
                                                }
    
                                                    else $z=0;
    
                                            }
    
                                            if(($ok==0)&&($z==0)){
                                                $result2 = mysql_query("SELECT * FROM categorii_menu");
                                                mysql_query("UPDATE  categorii_menu SET nume='$nume' , nr_ordine='$ordine' , grad_categorie='$grad', cale='$cale' , continut='$content' WHERE id='$id'");
                                                header('Location:lista_linkuri.php');
                                            }
                                            else if(($ok==1)&&($z==0))echo"Acest nr de ordine este deja luat";              
                    }
    
    
    
                    else {
                                            $id=$_GET["id"];
                                            $nume=$_POST['nume'];
                                            $cale=$_POST['cale'];
                                            $ordine=$_POST['ordine'];
                                            $content = stripslashes($_POST['content']); 
                                            $grad=0;
                                            $ok=0;
    
                                            $result=mysql_query("SELECT * FROM categorii_menu WHERE grad_categorie=$grad");
                                            while($data=mysql_fetch_row($result)){
                                            if($data[2]==$ordine) 
                                                {
                                                    $ok=1;
    
                                                    }
                                                }
                                            $result3=mysql_query("SELECT * FROM categorii_menu ");
                                            while($zata=mysql_fetch_row($result3)){
                                                if($nume==$zata[1]){
                                                   echo "Deja se foloseste acest nume"; 
                                                   $z=1;
                                                   break;
                                                }
                                                   else $z=0;
                                            }
    
                                            if(($ok==0)&&($z==0)){
                                                mysql_query("UPDATE categorii_menu SET nume='$nume',nr_ordine='$ordine',cale='$cale',grad_categorie='$grad',continut='$continut') WHERE id='$id'");
                                                header('Location:lista_linkuri.php');
                                            }   
                                                else if(($ok==1)&&($z==0))echo "Acest nr de ordine este deja luat";                 
    
    
    
                    }
            } else if( (isset($_GET["id"])) &&($_POST) ) echo"Nu ati completat toate campurile" ;
    
            //retrieves the modified data from the populated form (but only if all fields are modified :(  , i don't know how to overcome this inconvenience  ) - end
    
    
    
    }
    

    ?>

    Editare pagina

    tinyMCE.init({
    // General options
    mode : “textareas”,
    theme : “advanced”,
    plugins : “spellchecker,preview,searchreplace,paste,fullscreen,template”,

          // Theme options
        theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "removeformat,|,sub,sup,|,charmap,|,fullscreen",
        theme_advanced_buttons4 : "spellchecker,template",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
    
    
        // Skin options
        skin : "o2k7",
        skin_variant : "silver",
    
    
    
        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "js/template_list.js",
        external_link_list_url : "js/link_list.js",
        external_image_list_url : "js/image_list.js",
        media_external_list_url : "js/media_list.js",
    
        // Replace values for the template plugin
        template_replace_values : {
                username : "Some User",
                staffid : "991234"
        }
    

    });

    //initializare megamenu
    ddmegamenu.docinit({
    menuid:’solidmenu’,
    dur:200
    })

        <div class="butoane_lista_articole">
                <a href="lista_linkuri.php">Inapoi la lista</a>
        </div>
    
        <div id="pagina_noua_link" class="camp_linkuri2" >
            <div id="zona-date" class="titlu_pagina_noua">
                <form action="<?php $_PHP_SELF ?>" method="post">
                <span class="span_edit">Meniuri</span>
                    <select name="select">
    
                            <option value="">Pagina Principala Noua</option>
                                <?php
    
                                        $result=mysql_query("SELECT * FROM categorii_menu WHERE grad_categorie=0");
                                        while($data=mysql_fetch_assoc($result)){ ?>
                                         <option value="<?php echo $data['id']; ?>" <?php if($data['id']!="") {echo "selected"; ?> > <?php echo $data['nume'];}?></option> 
                            <?php       }
    
                                        ?>
    
                    </select>
    
            </div>
                                <?php 
                                if(isset($_GET["id"])){
                                        $id=$_GET["id"];
                                        $result=mysql_query("SELECT * FROM categorii_menu WHERE id=$id;");
                                        $data=mysql_fetch_row($result);
                                        echo '<label for="nume">Nume</label><input type="text" value="'.$data[1].'"name="nume" class="input_text"/>';
                                        echo '<label for="cale">Cale</label><input type="text" value="'.$data[4].'"name="cale" class="input_text"/>';
                                        echo '<label for="ordine">Nr ordine</label><input type="text" value="'.$data[2].'"name="ordine" class="input_text"/>';
                                    } 
                                      else  {?>
    
                                                <label for="nume">Nume</label><input type="text" name="nume" class="input_text" />
                                                <label for="cale">Cale</label><input type="text" name="cale" class="input_text"/>
                                                <label for="ordine">Nr ordine</label><input type="text" name="ordine" class="input_text"/>
                                        <?php }?>               
        </div>
    
                        <div id="articol_link">
    
                                <textarea name="content" style="width :100%; height:300px;">
                                    <?php 
                                    if(isset($_GET["id"])){
                                    $id=$_GET["id"];
                                    $v2 = mysql_query("SELECT * FROM categorii_menu WHERE id=$id ");
                                    $id2 = mysql_fetch_row($v2); 
                                    echo $id2[6]; 
                                    } 
                                    ?> 
                                </textarea>
                        </div>                      
    
                                <input type="submit" name="submit" value="<?php if(isset($_GET["id"])) echo "Salvare Modficari "; else echo "Adauga pagina";?>  " class="button2"/>
                </form>
    

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:55:22+00:00Added an answer on June 17, 2026 at 3:55 am

    you can update all the fields in the database which are in the form. All the fields will be updated with the current values.

    You can retrieve the data by $_POST[‘fieldname’] that you did already for insert

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jquery.ajax form which populates data from the database and auto fills
I am designing a database app, and have a form which populates with data
I am working on creating a form which pulls data from a database, and
I have a form which is filled with values retrieved from database. That form
I have an inout form which populates todays date automatically through the 'today' function.
I have a form which POST's its data via AJAX: $.ajax({ type: POST, url:
i have an form which will send some data to an php file ,
I am building a form in access database. I have a combo box which
i am reading data from a mysql database table. I have populated a dropdown
I have a form that a user fills out, which submits information to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.