I have this PHP
Code: Select all
$catList = mysql_query("SELECT * FROM adminCategory ORDER BY CategoryName");
$catLinks = array();
while ($catlistRow = mysql_fetch_array($catList)) {
$catLinks[] = '<a href="javascript:;" class="sortCat" id="sortCat_'.$catlistRow['id'].'" onclick="sortItemCat('.$catlistRow['id'].')">'. $catlistRow['CategoryName'] .'</a>';
}
echo "<p id=\"catSortList\">" . implode(' | ', $catLinks) . "</p>";
$result = mysql_query('SELECT * FROM adminItems ORDER BY id' . $catSortItem);
while ($row = mysql_fetch_array($result)) {
$textmsg = $line = str_replace("|", "</li><li>", $row['textmsg']);
$catID = $row['category_id'];
$catsql = "SELECT * FROM adminCategory WHERE id = " . $catID;
$catName = mysql_query($catsql);
while ($catRow = mysql_fetch_array($catName)) {
print '<div id="Item_' . $row['id'] . '" class="itemListBox">
<img src="../content/img/items/imgresize.php?src=../content/'.$row['image_url'].'&w=100" alt="'.$row['name'].'" title="'.$row['name'].'" class="itemListImg" />
<div><h3 class="itemTitle">' . $catRow['CategoryName'] . ' » '.$row['name'].'</h3>
<p class="itemDesc"><strong>Description: </strong>'.$row['description'].'</p>
<p class="itemMsg"><strong>Text Message(s): </strong></p>
<ol class="itemMsgList"><li>'.$textmsg."</li></ol></div>
</div>\n\n";
}
}The categories are linked to the jQuery so that I can show only the clicked on category.
I added this to the top of the PHP
Code: Select all
if(!empty($_POST) && !empty($_POST['catSortID'])) {
$catSortID = $_POST['catSortID'];
$catSortItem = " WHERE category_id = " . $catSortID;
} else {
$catSortItem = "";
}Code: Select all
function sortItemCat(id) {
var catList = $("#sortCat_"+id).text();
$.post('lib/loadItem.php', { catSortID: id }, function(data) {
if(data != 'false'){
$("#itemList").load("lib/loadItem.php");
}else{alert(data+" -- "+id+" -- "+catList);}
});
}I am not getting the else alert, so it is got into the loadItem.php code from above, but it is not actually rerunning the PHP with the sorting.
Any help or any further information would be helpful. If you need me to explain what I am doing further in depth please let me know.
Thanks!