0

Hi guys,
I've hit a wall again with this code and I'm sureit's something simple I'm doing wrong, I just can't see it.

<?php
 include('php/head.php');

// form action
$asset=$_POST['asset'];
$item=$_POST['item'];
$link=sqlite_open('data/3002.sqlite ',0666,$sqliteerror);
sqlite_query($link,"INSERT INTO holding(item)
VALUES('$item')");
sqlite_query($link,"DELETE FROM '$asset' WHERE item= '$item'");


// open page display div   
echo"<div class='image_pane'>";

// fetch data from db table 
$link=sqlite_open('data/3002.sqlite ',0666,$sqliteerror);
$res=sqlite_query($link,"SELECT * FROM chest");
while($row=sqlite_fetch_array($res)){
$img=$row['item'];

// form with images as inputs
 echo" 
    <form action='ins.php' method='post'>
    <input type='hidden' name='asset' value='chest'>
    <input type='hidden' name='item' value='".$img."'>
    <input type='image' src='images/".$img.".png' border='0'>
    </form>";
 }  

// close div
echo" </div>";

 include('php/foot.php');
?>

The display part works fine, 5 images shown, the problem is in the form action script,
click on any image, and only the last in line is acted on. i.e the images are: food, torch, knife, scarf, key.
Click on food, and key is removed from the 'chest' table and inserted into 'holding'.
Whichever one is clicked, it's only the right hand one is dealt with.
Something simple...probably.

1
Contributor
1
Reply
16
Views
4 Years
Discussion Span
Last Post by TonyG_cyprus
1

I knew it was something I was missing... added 'ORDER BY item' to sqlite query line 18 and it all works as required

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.