Here are the functions:
Code: Select all
function checkForDuplicates($iC){
$mysqlDupSearch = "SELECT ItemCode, Description FROM stock WHERE ItemCode = '".$iC."'";
$dupQuery = mysql_query($mysqlDupSearch);
$num = mysql_num_rows($dupQuery);
if($num > 0){
return false;
}else{
return true;
}
}Code: Select all
function insertNewStock($stockArray){
$mysqlAddStock = "INSERT IGNORE INTO stock (ItemCode, Product, Company, Brand, TypeOfProduct, Colour, Size, Shape, Length, Description, Quantity) values ('".$stockArray['itemCode']."','" .$stockArray['Product']."','" .$stockArray['Company']."','" .$stockArray['Brand']."','" .$stockArray['TypeOfProduct']."','" .$stockArray['Colour']."','" .$stockArray['Size']."','" .$stockArray['Shape']."','" .$stockArray['Length']."','" .$stockArray['Description']."','" .$stockArray['Quantity']."')";
if(!checkForDuplicates($stockArray['itemCode'])){
return 'The Record Already Exists!';
}else{
if(mysql_query($mysqlAddStock)){
$response = "<font size=3>The following item has been saved successfully:</font>";
$response = $response."<table border=1>";
$response = $response."<tr><td align=right><b>Item Code: </b></td><td align=right>".$stockArray['itemCode']."</tr>";
$response = $response."<tr><td align=right><b>Description: </b></td><td align=right>".$stockArray['Description']."</tr>";
$response = $response."<tr><td align=right><b>Product: </b></td><td align=right>".$stockArray['Product']."</tr>";
$response = $response."<tr><td align=right><b>Company: </b></td><td align=right>".$stockArray['Company']."</tr>";
$response = $response."<tr><td align=right><b>Brand: </b></td><td align=right>".$stockArray['Brand']."</tr>";
$response = $response."<tr><td align=right><b>Type Of Product: </b></td><td align=right>".$stockArray['TypeOfProduct']."</tr>";
$response = $response."<tr><td align=right><b>Colour: </b></td><td align=right>".$stockArray['Colour']."</tr>";
$response = $response."<tr><td align=right><b>Size: </b></td><td align=right>".$stockArray['Size']."</tr>";
$response = $response."<tr><td align=right><b>Shape: </b></td><td align=right>".$stockArray['Shape']."</tr>";
$response = $response."<tr><td align=right><b>Length: </b></td><td align=right>".$stockArray['Length']."</tr>";
$response = $response."<tr><td align=right><b>Quantity: </b></td><td align=right>".$stockArray['Quantity']."</tr></table><br>";
$response = $response."<a href='addNewStock.php'><button name='anotherStock'>Add Another</button></a>";
$response = $response."<a href='mainpage.php'><button name='mainpage'>Mainpage</button></a>";
return $response;
}else{
return "<p>Cannot insert new stock due to: ".mysql_error();
}
}
}I really am at the end of my tether here! ive totally ran out of ideas so if anyone can help me please please please dont hesitate to give advice!!
Many thanks in advance!