Jump to content

PHP side of a ajax request.


Xtremer360

Recommended Posts

This part of the question is based off of php so I'll put it here of course.

 

The idea behind this is jquery/ajax is going to get passed an id (eventid) from a dropdown select box inside a form and it's going to run a query to find all the events in my database with that same id. After running the query it's going to list them out and find the highest number of another field (label) and its going to add one to its value and then what I would like for it to is send it back to the form in the jquery/ajax and and place that label inside of the existing input text field in the form.

 

So I'm asking is if my code is presented and is doing what I"m attempting it to do on the php side and if so if I can take out the print tag of the input text field.

 

$eventid = $_GET['eventid'];
$result = mysqli_query("SELECT * FROM `events` WHERE `event_id` = '$eventid'");
$list = mysqli_num_rows($result);
$label = $list + 1;
print '<input type="text" name="label" class="text" readonly="readonly" value="' . $list . '" />';

Link to comment
Share on other sites

Perhaps this might explain it even better.

 

What I want it to to is when the user selects an if its the first event with that name meaning it'd be the first instance of that show itd be 1 for the label now when it comes time for the next show wiht that name it'll go into the database and see that there's already and instance of that show and it'll see that the label there is 1 so then it'll add one to that number and return 2 for the label

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.