Ivo
|
| Posted: 05/31/2003, 3:08 PM |
|
Hello!
I have the script to update a grid for PHP / CC2 working and I have the script to delete an record by checkbox working. But I don't know how to let it work together..
scripts:
--------------------------------------------------------------
HEADER of the Form:
<form name="grid" method="GET" action="shop.php">
--------------------------------------------------------------
Footer of the Form:
<input type=submit value=submit> </form>
--------------------------------------------------------------
Before show:
$fldbox = "<input type=checkbox name=" . $fldorderline_id . ">";
$fldaantal = "<input type=text name=" . $fldorderline_id . " value=". $fldaantal ." size=4>";
--------------------------------------------------------------
Page open event for delete:
$max = dLookUp("orderline", "max(orderline_id)", "1=1");
$min = dLookUp("orderline", "min(orderline_id)", "1=1");
for ($i=$min; $i<= $max; $i++)
{
$box = get_param("$i");
if ($box != "")
{
$sSQLd = "delete from orderline where orderline_id=".$i;
//or use update sql query
$db->query($sSQLd);
}
}
--------------------------------------------------------------
Page open event for update:
$max = dLookUp("orderline", "max(orderline_id)", "1=1");
$min = dLookUp("orderline", "min(orderline_id)", "1=1");
for ($i=$min; $i<= $max; $i++)
{
//echo $i." is ".get_param("$i")."<br>";
$quantity = get_param("$i");
if ($quantity != "")
{
$aantal = str_replace(",", ".", $quantity);
$sSQLu = "UPDATE orderline SET quantity=" . $quantity . " WHERE orderline_id=".$i;
$db->query($sSQLu);
}
}
--------------------------------------------------------------
Thanks for helping!!
Ivo
|
|
|
 |
Ivo
|
| Posted: 05/31/2003, 4:00 PM |
|
Please look at these scripts, the other have some mistakes.
scripts:
--------------------------------------------------------------
HEADER of the Form:
<form name="grid" method="GET" action="shop.php">
--------------------------------------------------------------
Footer of the Form:
<input type=submit value=submit> </form>
--------------------------------------------------------------
Before show:
$fldbox = "<input type=checkbox name=" . $fldorderline_id . ">";
$fldquantity = "<input type=text name=" . $fldorderline_id . " value=". $fldquantity ." size=4>";
--------------------------------------------------------------
Page open event for delete:
$max = dLookUp("orderline", "max(orderline_id)", "1=1");
$min = dLookUp("orderline", "min(orderline_id)", "1=1");
for ($i=$min; $i<= $max; $i++)
{
$box = get_param("$i");
if ($box != "")
{
$sSQLd = "delete from orderline where orderline_id=".$i;
//or use update sql query
$db->query($sSQLd);
}
}
--------------------------------------------------------------
Page open event for update:
$max = dLookUp("orderline", "max(orderline_id)", "1=1");
$min = dLookUp("orderline", "min(orderline_id)", "1=1");
for ($i=$min; $i<= $max; $i++)
{
//echo $i." is ".get_param("$i")."<br>";
$quantity = get_param("$i");
if ($quantity != "")
{
$quantity = str_replace(",", ".", $quantity);
$sSQLu = "UPDATE orderline SET quantity=" . $quantity . " WHERE orderline_id=".$i;
$db->query($sSQLu);
}
}
--------------------------------------------------------------
|
|
|
 |
Nicole
|
| Posted: 06/02/2003, 6:10 AM |
|
Hello,
Ill try to point you to right direction. In order to create Grid with Delete and Update functionality you should add checkbox to the form. E.g.:
$fldbox = "<input type=checkbox name=del." . $flditem_id . " value=OFF>";
Then the query string would look like:
Page_name.php?25=25&27=27&del27=27&28=28&del.28=OFF&29=29
So in the page’s Open event you should add the code that search for "del.=" string and retrieves the id after equals ("=") sign. The record with mentioned id is to be deleted.
|
|
|
 |
Ivo
|
| Posted: 06/02/2003, 12:47 PM |
|
Thanks Nicole, it is more clear now. But I'm not a good PHP programmer and maybe you or somebody else can please help me a bit more.
I understand the before show and I have the query string you told me, but I don't know how to make the page's open event.
Do I have to make from the 2 different open events (delete and update) one?
Like:
$max = dLookUp("orderline", "max(orderline_id)", "1=1");
$min = dLookUp("orderline", "min(orderline_id)", "1=1");
for ($i=$min; $i<= $max; $i++)
{
//echo $i." is ".get_param("$i")."<br>";
$box = get_param("$i");
$quantity = get_param("$i");
if ($box != "")
{
$sSQLd = "delete from orderline where orderline_id=".$i;
$db->query($sSQLd);
}
else
{
if ($quantity != "")
{
$quantity = str_replace(",", ".", $quantity);
$sSQLu = "UPDATE orderline SET quantity=" . $quantity . " WHERE orderline_id=".$i;
$db->query($sSQLu);
}
}
}
Sorry I'm on a dead road...
|
|
|
 |
Ivo
|
| Posted: 06/03/2003, 11:58 PM |
|
Can anyone please help me? I don't know what to do now and it is very urgent
. It looks like a lot of script, it is but very easy. I think I'm close. I have the script working for update able script and for deletion script to use in a grid. But now I have to do these 2 things together in one form...
Best Regards,
Ivo
|
|
|
 |
|