The jQuery code should be as follows

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);}
        });
}



On Jan 26, 9:24 pm, Good Knight <kyleakni...@gmail.com> wrote:
> Okay, so I have This PHP code.
> It creates a list of all the categories from database and it creates a
> div with all the items from the database. Each item is associated with
> a category id as to which category it is apart of. The list of
> categories should be clicked on and then the jQuery will run a post of
> the category id and then reload the list of items to only show items
> in the selected category.
>
> if(!empty($_POST) || $catSortID != "") {
>         $catSortID = $_POST['catSortID'];
>         $catSortItem = " WHERE category_id = " . $catSortID;} else {
>
>         $catSortItem = "";
>
> }
>
> $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>\n
> \n";
>
> $result = mysql_query('SELECT * FROM adminItems'.$catSortItem.' ORDER
> BY id');
> 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'] . '
> &raquo; '.$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";
>         }
>
> }
>
> Problem is, whenever jQuery runs a post and then loads it, it never
> returns with only the selected category items.
>
> function sortItemCat(id) {
>         var catList = $("#sortCat_"+id).text();
>         $.post('lib/loadItem.php', { catSortID: id }, function(data) {
>                 if(dataq){
>                         $("#itemList").load("lib/loadItem.php");
>                 }else{alert(data+" -- "+id+" -- "+catList);}
>         });
>
> }
>
> Any idea as to what might be going on?

Reply via email to