Im very new to php, but im trying to create a bit of code that you type in the part number and quantity you want and it returns the part number and the word "limited" if its the same "not enough" if it's less than and "in stock" if its more than, im having trouble getting it to say the word in the end column where i want it.
Here is the code, but please remember im very new to it so it might be a complete mess
<form id="search" name="form" action="stock.php" method="get">
<input type="text" name="partnum" width="50"/>
<input type="text" name="quantity" width="50"/>
<input type="submit" name="Submit" value="Search" />
</form>
<?php
include("namefile");
$pt = @$_GET['partnum'] ;
$qty = @$_GET['quantity'] ;
// check for an empty string and display a message.
if ($qty == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
// check for an empty string and display a message.
if ($pt == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
//connect to mysql
$connection = mysql_connect($host,$account,$password)
or die ("Couldn't connect to server");
//select which database you want to edit
$db = mysql_select_db("dbname",$connection)
or die ("Couln't connect to database");
$out = "Out of stock";
$in = "In Stock";
$exact = "Exact";
// SQL Query
$string = ("SELECT * FROM table WHERE stock >= $qty AND part = \"$pt\"")
or die("Please enter a part number");
$qresult = mysql_query("SELECT part,stock FROM table WHERE stock >= $qty AND part = \"$pt\"");
$query = mysql_query($string) or die (mysql_error());
$row = mysql_fetch_array($qresult);
{
do
{
echo "<table style='font-size:10px; font-family: arial;' width=1000px>";
echo "<tr>";
echo "<td width='20%'>".$result[part]."</td>";
echo "<td width='40%'>".$result[desc]."</td>";
echo "<td width='20%'>".$result[xref]."</td>";
echo "<td width='20%'>".$result[zref_model]."</td>";
echo "<td width='20%'>".$result[stock]."</td>";
echo "</tr>";
echo "<tr><td colspan='5'><hr></td></tr>";
echo "</table>";
}
while($result = mysql_fetch_array($query));
}
if(!$qresult || $row['stock'] < $qty) {
echo "$out";
}
elseif(!$qresult || $row['stock'] > $qty) {
echo "$in";
}
elseif(!$qresult || $row['stock'] = $qty) {
echo "$exact";
}
?>