Hi jon and ray
thanks to you both, I have used lynda.com but due to my job (i drive truck here in the uk) i only part time design so getting to watche the darn videos is a pain, I got the stock control done for $20 by a coder, so all is not lost but ray, where was that answer a long time ago? :) I know i need to learn it, i wish i had the time for someone to sit down and teach me php so that i can just code like i do with html/css. but i agree lets keep the thing going for now, this is the code used on my cart.php page
On my cart.php page it is like this (just to make sure they can't add anything if bought before checkout and passed to paypal,)
$avail_stock = $_POST['txtstockQty'];
mysql_select_db($database_beads2, $beads2);
$query_RSclasses = "SELECT * FROM content WHERE ContentID = 2";
$RSclasses = mysql_query($query_RSclasses, $beads2) or die(mysql_error());
$row_RSclasses = mysql_fetch_assoc($RSclasses);
$totalRows_RSclasses = mysql_num_rows($RSclasses);
<script type="text/JavaScript">
function checkstock(v1,name1){
var value1=v1;
var x=name1.length;
var pnum = name1.substring(15,name1.length);
var cname = "qty" + pnum;
var avail_stock=document.getElementById(cname).value;
var pur_stock = document.getElementById(name1).value;
if(parseFloat(avail_stock)<parseFloat(pur_stock)){
alert("The available stock is "+avail_stock);
for (var i=0;i < document.cartfrm.elements.length; i++) {
if (document.cartfrm.elements[i].type=="text" && document.cartfrm.elements[i].name==name1) {
document.cartfrm.elements[i].value="";
document.cartfrm.elements[i].focus();
return false;
}
}
}
}
</script> (feel free to use if needed)
and also this
<?php
while (!$Beads->EOF()) {
$item_id = $Beads->DisplayInfo("ID");
mysql_select_db($database_beads2, $beads2);
$sql = "SELECT * FROM items WHERE ItemID=".$item_id;
$Result = mysql_query($sql, $beads2) or die(mysql_error());
$rs = mysql_fetch_assoc($Result);
$stock_qty=$rs['ItemAv'];
?>
ray please correct me if you feel anything like this is wrong. Hope this helps people out there,