0

I need some help figuring this out, since I have been using a lot of time on it, and simply can't get my head around it...

I have a row in my table called 'Presets', where I would like to change the value, which is 'Normal' to 'Event'. I would like to do this with the click of a button on my website, as I have already figured out how to change the design, when I manually change it in the DB.

HTML:

<ul class="dropdown-menu">
        <li><a href="#" id="presetchange">Event</a></li>
        <li><a href="#">#2</a></li>
        <li><a href="#">#3</a></li>
    </ul>

Jquery:

$("#presetchange").on('click', function() {
        $.ajax({
            url: "../presethandler.php"
        });
    });

PHP:

require("connection.php");
mysql_query("UPDATE dashboard SET preset = 'Event' WHERE user_id = '1'");
ChristianLD
  • 21
  • 1
  • 3
  • 1
    If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jul 20 '15 at 13:29
  • What is not working here? – Jay Blanchard Jul 20 '15 at 13:29
  • Well I'll be damned... I will definitely read up on this! Thank you. I guess the real issue I'm facing is, how to properly use Ajax to do the 'on click' feature on my site.. – ChristianLD Jul 20 '15 at 13:32
  • With what you have posted I can see no problem with your AJAX. – Jay Blanchard Jul 20 '15 at 13:34
  • Id should be unique for each `li` or use class instead. – Jitendra Yadav Jul 20 '15 at 13:38
  • Oh my. I figured it out.. Thank you Jay Blanchard! I guess I just needed someone to tell me it actually wasn't wrong, so I could figure it out.. Definitely learned something by this.. And I will read up on what you linked :). – ChristianLD Jul 20 '15 at 13:44

0 Answers0