Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

mysql record change

Options
  • 21-01-2009 9:34pm
    #1
    Registered Users Posts: 3,875 ✭✭✭


    Hi Just a quick query I have a table of registered people to an event

    I have the table repeated for all values of the recordset so everyone who is registered to the event has their own row with their details , registration id, status etc.

    I know want to allow the admin staff to change their status to completed from processing.

    The way I know of doing this would be to have a cancel link that sends to and edit page where all fields are hidden and upon submitting the value would get changed.

    I would prefer however if it was possible to have two buttons on the table one for completed and one for failed, and as soon as the button is pushed that status will update accordingly.

    this way it would be much quicker to mark all as completed for example.

    is this possible?
    can anyone point me in the right direction.


Comments

  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    I'm not 100% sure what you mean, but if you are looking at editing multiple records at the the same time, you could either create administration forms in PHP to allow you to edit multiple records at the same time. Or usually the ISP has some sort of MySQL administration tool builtin, like myPHPAdmin (I think), which will allow you to edit the records.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    ah, i think what you're looking for is to be able to press the buttons to update the status without having to reload the page? if that's the case, you have a couple of options. you could use checkboxes instead of buttons, and have a button to update the details for the rows with checked boxes.

    alternatively, if you want to keep the buttons and do them one by one, you want to make an ajax script to handle the button.


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    I just want to have a table that shows all registrations and create a button taht changes the value of a field (status) for that aprticular record.

    I don't want the people using this to have access to phpmyadmin because they dont know what they are doing.


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    so this is what I have in my table at the moment, you can see what I am trying ot do but it is not working

    <td><?php echo $row_Recordset1; ?></span></td>
    <td><?php echo $row_Recordset1; ?></td>
    <td><?php echo $row_Recordset1; ?></td>
    <td><?php echo $row_Recordset1; ?></td>

    <td><form id="form1" name="form1" method="post" action="">
    <input name="passed" type="submit" id="passed" onclick= $row_Recordset1 = 'passed' value="passed" />
    </form>

    my hope was that when you clicked the passed button it would update the status from proccessing to passed.


  • Registered Users Posts: 26,579 ✭✭✭✭Creamy Goodness


    your form has no action where is form data being submitted to?

    your onclick function will not work as you are mixing html with php value.

    you have two options from what i can see.

    have a AJAX function that calls a php script on your site that will update the 'Status' field in the database once the passed button is clicked.

    or

    have the form submit on itself

    <td><form id="form1" name="form1" method="post" action="./myform.php">

    and then at the top of the myform.php script check that $_GET is set, if it is, then update the record in your database table.


  • Advertisement
  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    your form has no action where is form data being submitted to?

    your onclick function will not work as you are mixing html with php value.

    you have two options from what i can see.

    have a AJAX function that calls a php script on your site that will update the 'Status' field in the database once the passed button is clicked.

    or

    have the form submit on itself

    <td><form id="form1" name="form1" method="post" action="./myform.php">

    and then at the top of the myform.php script check that $_GET is set, if it is, then update the record in your database table.

    Ok I think I will try the second option there

    so i get my form to submit itself

    how exactly do i do the other steps?


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    would this not require a new form for every record?


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    ah fantastic i got it working in a way I am delighted each record has its own form a hidden if field and a drop down list of passed/cancelled that changesd status thanks.


  • Registered Users Posts: 26,579 ✭✭✭✭Creamy Goodness


    k you'd have something like this as a php script.

    i'm going to do this in comments as it seems like a college assignment and don't want to give you the full solution cause otherwise you won't learn that way.

    read the lines beginning with //

    myform.php

    [php]
    //here is where we'll check the form values being passed
    //get the value of the hidden field 'submitted' here

    //get if it is set using the isset() function.

    //if the isset() returns true it means someone clicked the 'passed' button and submitted the form.
    //update the database here using UPDATE SQL.

    //NOW THE RECORD IN THE DB WILL CONTAIN 'PASSED' INSTEAD OF 'PROCESSING'
    //so now when the page refreshes the output will say 'passed' instead of 'processing'.


    //display the record (obviously be connected to DB first).

    <td><?php echo $row_Recordset1; ?></span></td>
    <td><?php echo $row_Recordset1; ?></td>
    <td><?php echo $row_Recordset1; ?></td>
    <td><?php echo $row_Recordset1; ?></td>


    //here set the action to the filename of this script
    <td><form id="form1" name="form1" method="post" action="./myform.php">

    //have a hidden field with the value to send.
    <input type="hidden" name="submitted" value="yes"/>
    <input name="passed" type="submit" id="passed" value="passed" />
    </form>

    [/php]

    this wouldn't be the way i'd go about this but it's the simplest that i can think of...

    *EDIT* see ya got it working, nice one.


Advertisement