hello i made a litle website where i am selling some staffs , on my website i have SQL databese where that stafs are stored , i made a PHP page where from where peoples can order things that i have for sell problem is in my Database i have a fild that is call Lager i put there how much for exemple books i have at this time ... so man who want to bay hi click on book that hi want and that go to shoping cart but ... when hi enter how much books hi want ... shoping cart make order for that even if i dont have that much right now ! so i need to make a funkcion that will take a look to DB and lager fild.. how muhc books are there and if there is no that much book to not make a order.. now it look like this

PHP Code:
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<=999){
                
$_SESSION['cart'][$i]['qty']=$q;
            }
            else{
                
$msg='no that much products !, quantity must be a number between 1 and 999';
            }
        }
    } 
function

PHP Code:
function get_lager($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']; 
i need to inplement some funkcion like this one .. so it call database for selekted and see what number is in DB if number is lower then number that man order to get him mesage .. that cant be done ...

Big THANKS for help ! and sorry for my bad ENG