mardi 22 mars 2016

Php/sqlite database not returning result

Im currently attempting to create a small program in php/sqlite (I am VERY new to php and sqlite) where I can populate the quantity of already stored products and also add in new products aswel.

I already have a database made which has numerous entries within it.

Ive managed to create this code however it isn't returning anything or giving me any errors.

Would someone be able to point out what ive done wrong or a possible solution?!

Here is my code...

<?php

$db=sqlite_open("warehouse.db");

if(isset( $_POST['warehouse']) && strcmp($_POST['warehouse'],"") !=0 ){

    $ItemID = sqlite_escape_string($_POST["warehouse"]);

    $ItemName=$_POST['warehouse'];

    $Quantity=$_POST['warehouse'];

$qr="UPDATE warehouse SET Quantity = $Quantity WHERE ItemName = (SELECT id FROM warehouse WHERE itemName='$ItemName')";

    sqlite_query($db,$qr);

echo "<h2>". "Show warehouse"."</h2>";

echo "<table border=1>\n";

echo "</br>\n";

$result=sqlite_query($db,"SELECT * from warehouse WHERE warehouse.ItemName = warehouse.id");

echo "<th>Item ID</th><th>Item Name</th><th>Item Quantity</th>\n";

while($row=sqlite_fetch_array($result,SQLITE_ASSOC))
{
    echo "<tr>\n";
    echo "<td>" . $row['warehouse.ItemId'] . "</td>\n";
    echo "<td>" . $row['warehouse.ItemName'] . "</td>\n";
    echo "<td>" . $row['warehouse.Quantity'] . "</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";


}
sqlite_close($db);

?>

Aucun commentaire:

Enregistrer un commentaire