Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Beginner needs some quick help

    I am a beginner and need some quick help. Will pay if necessary.

    Help #1: I need to copy records from table checklistform to table checklist_history.. The min number records per prod_id will be 12

    //Step 1 - copy all existing records Checklistfrom where prop_id is the one being made vacant and insert into Checklist_history.
    $mysql1 = "INSERT INTO Checklist_history SELECT * FROM Checklistform WHERE prop_id='$prop_id'";

    //Step 2 - delete records from Checklistform where prod_id is being made vacant.
    $mysql2 = "Delete from Checklistform where prop_id='$prop_id'"; mysql_query($sql);

    Help #2: Put a variable in confirm text.
    form action="owner_changeto_vacantproperty.php?prop_id=" method="post" enctype="multipart/form-data" name="vacant" id="vacant" onSubmit="return confirm_deactivate()">

    <script language='JavaScript'>
    function confirm_deactivate()
    {
    var yes=confirm('Are you sure you wish to deactivate this property! (would like to show the $prop_id');
    if (yes)
    return true ;
    else
    return false ;
    }
    </script>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    Nothing to do with MySQL, per se. You need to learn more about HTML and PHP.

    This makes no sense:
    Code:
    <form action="owner_changeto_vacantproperty.php?prop_id=" method="post" ...
    If you are going to use method="post" (which you probably should) then you do NOT want to also try to send the postid as part of the query string.

    Also, confirm() is considered obsolete JavaScript, best to be avoided.

    I think you need to show us your complete <form>...</form> before we go further.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Like I said I am not a coder nor I am going to be...
    I have developed and idea and doing the coding to create a working model..
    If the idea gains traction, then i will hire a coder to do the site in good and current standards.

    Here is the correct line:

    <form action="owner_changeto_vacantproperty.php?prop_id=<?php echo $prop_id;?>" method="post" enctype="multipart/form-data" name="vacant" id="vacant" onSubmit="return confirm_deactivate()">
    But putting the variable into the confirm box - is secondary to the second task.

    Copy records from table checklistform to table checklist_history,

    Thanks

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    And like I said, show us your *COMPLETE* <form>. From the <form> tag through the </form> tag.

    Having said that, I see nothing obviously wrong with your SQL code, but it would depend entirely on the structure of your two DB tables.

    But it could be your PHP code, not related to MySQL, per se. You choose to show us virtually none of your code, so who knows?

    Until/unless you are willing to show your code there's not much anyone can do.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I actually thought this was simple based on the examples I found how to code onsubmit into the form line.

    Task one - putting a variable into the confirm text <?php echo $prop_id; ?>. It is not critical - will find the solution.

    Task two the sql statements:
    sql1 - both tables are identical in terms of fields. when i ran the page - it did not copy the records from checklistform to checklist_history but the second sql2 - delete worked.

    Thanks for the help - but because i am new to this I think I am better off finding a local coder where I can communicate via phone if necessary.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    *SIGH*

    The confirm thing is trivial.
    Code:
    <form action="owner_changeto_vacantproperty.php?prop_id=<?php echo $prop_id;?>" 
        method="get" id="vacant" onSubmit="return confirm_deactivate('<?php echo $prop_id;?>');"> 
    ...
    </form>
    
    <script type="text/javascript">
    function confirm_deactivate(id) 
    { 
        return confirm('Are you sure you wish to deactivate property with id ' + id + '?');
    } 
    </script>
    But that has NOTHING to do with MySQL. It should have been asked in the JavaScript forum.

    I'm sure your other problem could be easily fixed, too, if you'd be willing to SHOW YOUR CODE. Do you somehow think that your code is too secret to show here? Trust me, it isn't.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the coding will try it - but why change method=get from post...
    I understand the rest of it...

    Based on my test marketing with potential clients...rather not give all the coding..

  • #8
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry - I wanted to thank you for your help in task one - the confirm text.

  • #9
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks to all - I have my answers now...appreciate the patience.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    Why change post to get? Because you are passing the prop_id *IN THE QUERYSTRING* as I tried to point out:
    Code:
    <form action="owner_changeto_vacantproperty.php?prop_id=<?php echo $prop_id;?>" ...
    and so it is POINTLESS to use method=post.

    *IF* you have other elements in the <form> that need to be send via method=post, then you should *NOT* be using a querystring in the action= of the <form> tag.

    If that's really what you want, then you should use
    Code:
    <form method="post" action="owner_changeto_vacantproperty.php" ...>
    <input type="hidden" name="prop_id" value="<?php echo $prop_id;?>" />
    ...
    </form>
    so that *all* the form values are sent as post, not a hodge-podge of some post and some get.

    *********

    Based on my test marketing with potential clients...rather not give all the coding..
    Then I guess you would rather not get all the help you need.

    What you are doing here isn't anything that hasn't been done THOUSANDS AND THOUSANDS of times throughout the web for the last 15+ years. If you think you are inventing something new and magical, you are badly deluding only one person: yourself.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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