dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to retrived records in grid from mysql db to php form

  1. #1
    Join Date
    Sep 2015
    Posts
    1

    how to retrived records in grid from mysql db to php form

    hi all
    i want to fetch data from mysql database table in grid in php with checkboxes.
    when user select checkbox only selected data should be copied to other table and unselected data should be deleted from table.
    ex. I have 2 tables request and users
    and in my form i have 2 button approve and disapprove
    in form all records from request table will be shown in grid with checkbox
    when user select some checkboxes only selected data will be transfer to users table and unselected daata will be deleted from request table.
    i am learning php .. guys please help

  2. #2
    Join Date
    Sep 2015
    Posts
    17
    PHP only executes off the server, what you need is combination of html, css, ajax, javascript, php & sql commands.

    If your using check boxes you need to use ajax which send a request to a php script on the server this php script will send a query to the database, returning the results to the ajax request while using javascript to create the tables in html & css, although with out a working database this request is rather vague.

  3. #3
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    1,194
    As Codex says - your question presents some rather advanced programming techniques. From what I gather you want to display two tables on the screen and using a checkbox, move a set of data from what table to the other table. Correct?

    To do that in real-time without a refresh of the page you do need to do some new technologies. OTOH - if you can live with the refresh and a call to the server to achieve your end result, simply make each row of your table #1 a form by itself and use a button rather than a checkbox. A click on a button will trigger a call to your server script where you can take the data from that form and put it into the set of data in your table #2, removing it from the table #1 data. Then your script simply re-builds the page and sends it back. Of course this means using a session var to keep track of the data in table #2 and another to eliminate those records from table #1.

    I am imagining that you would have a set of record keys that comprise the total set of data. To start all the records belong to one html table. As you go thru the selection process to move things you would have to split that set of keys into the #1 keys and the #2 keys. I would use two session vars to hold these during the process. Then you could use those two sets (arrays?) of keys to query your db twice - once to re-build the table #1 output and once for the #2 output.

    I am also changing your design from having the ability to do multiple selections at a time. If you want to do that, then you would have to use checkboxes all in one form where each box held the value of that record's key. Then you could still build the two session vars I mentioned, adding the key to the #2 var and removing it from the #1 var. Then do the re-build.

    Sounds complicated but at this point in your development this will be a bit easier.
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


    at the top of ALL php code while you develop it!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles