how can i add products to the cart wihtout refreshing the product list?
<p>I made a simple  shopping  cart function  but I have 2 problems now. 1 is my product list is so big and my cart and my product list are in same page. When visitor click on add button its take too long time to reload how can make it work without refreshing the product page I mean add the product to cart without the refreshing the product page?  And my second problem is I want a product’s stock update function how can I make a product update function form that cart function?
Here is my code</p>

<pre><code>&lt;?php 
session_start();

$page = 'producst.php';


// my add function
if (isset($_GET['add'])) {
    $quantity = mysql_query('SELECT id, quantity FROM products WHERE id='.mysql_real_escape_string((int)$_GET['add']));
    while ($quantity_row = mysql_fetch_assoc($quantity)) {
        if ($quantity_row['quantity']!=$_SESSION['cart_'.(int)$_GET['add']]){
            $_SESSION['cart_'.(int)$_GET['add']]+='1';
        }
    }
    header('Location: '.$page); 
}


// my product list funtion
function products(){
    $result = '';
    $get = mysql_query('SELECT id, name, description, price FROM products WHERE quantity &gt; 0 ORDER BY id DESC');
    if (mysql_num_rows($get)==0) {
    }else{
         while ($get_row = mysql_fetch_assoc($get)) {
             $result .= '&lt;p&gt;'.$get_row['name'].'&lt;br /&gt;'.$get_row['description'].'&lt;br /&gt;&amp;pound;'.$get_row['price'].' &lt;a href="cart.php?add='.$get_row['id'].'"&gt;add&lt;/a&gt;&lt;/p&gt;';
             }
    }
    return $result;
}

// my cart function
function cart() {
    $result = '';
    foreach($_SESSION as $name =&gt; $value){
        if ($value&gt;0) {
            if (substr($name, 0, 5)=='cart_') {
                $id = substr($name, 5, (strlen($name)-5));
                $get = mysql_query('SELECT id, name, price FROM products WHERE id='.mysql_real_escape_string((int)$id));
                while ($get_row = mysql_fetch_assoc($get)) {
                    $sub = $get_row['price']*$value;
                    $result .= $get_row['name'].' x '.$value.' @ &amp;pound;'.$get_row['price'].' = &amp;pound;'.$sub.'&lt;br /&gt;';
                }
            }
        }
    }
    return $result;
}
?&gt;
</code></pre>
