This topic is locked

How would I write this asp code in PHP

11/27/2006 11:07:57 AM
PHPRunner General questions
I
iandouglas author

I found this on the asprunner forum and was wondering how I would would write this in PHP.
Add Page

CODE

Function BeforeAdd(dict)
strSQLInsert ="UPDATE class_names SET class_amount=(class_amount-1) WHERE class_name ='"&dict("YourDropdownField")&"'"
dbConnection.Execute strSQLInsert
BeforeAdd = True

End Function
List Page

CODE

Function BeforeDelete(where)
str = "select Battle_Date from class_names where" & where

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
strSQLInsert ="UPDATE class_names SET class_amount=(class_amount+1) WHERE class_name ='"&rsTemp("YourDropdownField")&"'"

dbConnection.Execute strSQLInsert

BeforeDelete = True

End Function
Your drop down box would need something like this in the "Where" option.

CODE

"class_amount>=1"
This is only a sample.
I'm testing the PHPrunner for the school I work at and this is exactly what we are looking/trying to do.
Thanks for any help!!
ID

J
Jane 11/28/2006

Hi,
here is a sample code:

function BeforeAdd(&$values)

{

global $conn;

$strSQLInsert ="UPDATE class_names SET class_amount=(class_amount-1) WHERE class_name ='".$values["YourDropdownField"]."'";

db_exec($strSQLInsert,$conn);

return true;

}


function BeforeDelete($where)

{

global $conn;

$str = "select Battle_Date from class_names where ".$where;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
$strSQLInsert ="UPDATE class_names SET class_amount=(class_amount+1) WHERE class_name ='".$data["YourDropdownField"]."'";

db_exec($strSQLInsert,$conn);
return true;

}

I
iandouglas author 11/28/2006

Thank you so much. The first part of the code works great but the last part is not updating the class_amount field.
I wonder if it has something to do with this line:
str = "select Battle_Date from class_names where" & where
What does Battle_Date mean <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13294&image=1&table=forumreplies' class='bbc_emoticon' alt=':wacko:' />
I'm getting this php error: Unknown column 'Battle_Date' in 'field list'
Thanks again...You all are really awesome!!
id

J
Jane 11/29/2006

Battle_Date is your actual field name in the class_names table.

You can use the following query:

$str = "select * from TableName where ".$where;

I
iandouglas author 11/29/2006

Thank you so much for your help.
I forgot to post last nite that I figured it out after alot of trying. I'm learning. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13320&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />
I also got it working for the edit page. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13320&image=2&table=forumreplies' class='bbc_emoticon' alt=':D' />
I will say this again, you guys are the best!!
id