I am not very knowledgable with AJAX and I am pretty certain it's the solution to my problem.
I want to update a php variable on a <TH> onclick. That variable will then be used to sort some columns of mine using a Jquery table sorting script.
At the top of the page (bodyshops.php) I have this...
if (isset($_GET['sortStore'])) {
$sortStore = $_GET['sortStore'];
}else{
$sortStore = 'EMPTY';
}
at the table end I have this... (I put $sortStore = 'X' as an example)
<th style="text-align:left; cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '1' ?>"><?php echo $LANGT_Bodyshop_Name; ?></th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '1' ?>"> <?php echo $LANGT_Bodyshop_Contact; ?></th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '2' ?>"> <?php echo $LANGT_Bodyshop_Email; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '3' ?>"> <?php echo $LANGT_Bodyshop_Phone; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '4' ?>"> <?php echo $LANGT_Bodyshop_AddressPostcode; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '5' ?>"> <?php echo $LANGT_Bodyshop_Capacity; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '6' ?>"> <?php echo $LANGT_Bodyshop_CourtesyCars; ?> </th>
The end goal is to be able to write up an if statement to decide what jQuery script to run.
i.e.
if ( $sortStore != 0 ) {
// Run Function 1
}else{
// Run Function 2
}
This would ultimately help me stopping TableSorter losing it's sort value when refreshing the page. Can anyone help?