This topic is locked

only check the selected / record field exists

1/9/2007 7:44:34 AM
PHPRunner General questions
D
datapimp author

Sorry for the noob question but still a bit new to all this...
on the events sections > View page > on load. I'm trying to modify the "check if specific record exists" so that it only checks the field of the selected item not the entire field. I also want to replace that data with a different value not add a new data entry., I'm having no luck.
Hope this made senses ,
Thanks

J
Jane 1/9/2007

Here is a sample code of the ViewOnLoad event:

function ViewOnLoad()

{

global $where;

global $conn;

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

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data["FieldName"]=="your value")

{

// if record exists do something

$strUpdate = "update TableName set FieldName='your new value'";

db_exec($strUpdate,$conn);

}

else

{

// if dont exist do something else

}

}

D
datapimp author 1/9/2007

Thanks soooooooooo much Jane for the speedy reply ... it work first go :-)