i bild litle webpage and seling some staffs there but in my shopingcart when visiter enter some big number shoping cart calculate price for it even there is no that much products in DB ... so i need just a litle part of code that will "take a look in DB in fild lager" and if there is no that much what visitor enter to get message that there is no that much products right now ! here is code of shoping cart

PHP Code:
<?php 
    
include("includes/db.php"); 
    include(
"includes/functionss.php"); 
    include(
"languages/frontend.ch.php"); 
        
//$db = $_SESSION['database']; 
    
if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){ 
        
remove_product($_REQUEST['pid']); 
    } 
    else if(
$_REQUEST['command']=='clear'){ 
        unset(
$_SESSION['cart']); 
    } 
    else if(
$_REQUEST['command']=='update'){ 
        
$max=count($_SESSION['cart']); 
        for(
$i=0;$i<$max;$i++){ 
            
$pid=$_SESSION['cart'][$i]['productid']; 
            
$q=intval($_REQUEST['product'.$pid]); 
            if(
$q>&& $q<=500){ 
                
$_SESSION['cart'][$i]['qty']=$q
            } 
            else{ 
                
$msg='Some proudcts not updated!, quantity must be a number between 1 and 999'
            } 
        } 
    } 

?>
this is functions .... i add a function to get how much products are in DB but i dont know how to inplement it on shoping cart

PHP Code:
<?php 
    
function get_product_name($pid){ 
        
$result=mysql_query("select Art from druckfederi where artnr=$pid") or die("select Art from druckfederi where artnr=$pid"."<br/><br/>".mysql_error()); 
        
$row=mysql_fetch_array($result); 
        return 
$row['Art']; 
    } 
    function 
get_price($pid){ 
        
$result=mysql_query("select cena from druckfederi where artnr=$pid") or die("select art from products where artnr=$pid"."<br/><br/>".mysql_error()); 
        
$row=mysql_fetch_array($result); 
        return 
$row['cena']; 
    } 
    function 
get_stanje($pid){ 
        
$result=mysql_query("select stanje from druckfederi where artnr=$pid") or die("select art from products where artnr=$pid"."<br/><br/>".mysql_error()); 
        
$row=mysql_fetch_array($result); 
        return 
$row['stanje']; 
    } 
    function 
remove_product($pid){ 
        
$pid=intval($pid); 
        
$max=count($_SESSION['cart']); 
        for(
$i=0;$i<$max;$i++){ 
            if(
$pid==$_SESSION['cart'][$i]['productid']){ 
                unset(
$_SESSION['cart'][$i]); 
                break; 
            } 
        } 
        
$_SESSION['cart']=array_values($_SESSION['cart']); 
    } 
    function 
get_order_total(){ 
        
$max=count($_SESSION['cart']); 
        
$sum=0
        for(
$i=0;$i<$max;$i++){ 
            
$pid=$_SESSION['cart'][$i]['productid']; 
            
$q=$_SESSION['cart'][$i]['qty']; 
            
$price=get_price($pid); 
            
$sum+=$price*$q
        } 
        return 
$sum
    } 
    function 
addtocart($pid,$q){ 
        if(
$pid<or $q<1) return; 
         
        if(
is_array($_SESSION['cart'])){ 
            if(
product_exists($pid)) return; 
            
$max=count($_SESSION['cart']); 
            
$_SESSION['cart'][$max]['productid']=$pid
            
$_SESSION['cart'][$max]['qty']=$q
        } 
        else{ 
            
$_SESSION['cart']=array(); 
            
$_SESSION['cart'][0]['productid']=$pid
            
$_SESSION['cart'][0]['qty']=$q
        } 
    } 
    function 
product_exists($pid){ 
        
$pid=intval($pid); 
        
$max=count($_SESSION['cart']); 
        
$flag=0
        for(
$i=0;$i<$max;$i++){ 
            if(
$pid==$_SESSION['cart'][$i]['productid']){ 
                
$flag=1
                break; 
            } 
        } 
        return 
$flag
    } 

?>
I REALY need this so if there is enyone that can help me that will be nice , i hope there is someone that understand what i wanted to say , sorry for my bad ENG