PHP Classes


Recommend this page to a friend!

      Auto Insert  >  All threads  >  Insert  >  (Un) Subscribe thread alerts  
Summary:Insert value from query
Author:Jose Gomes
Date:2008-08-01 11:47:07
Update:2008-08-17 15:31:33

  1. Insert   Reply   Report abuse  
Jose Gomes - 2008-08-01 11:47:07
Sorry, I'm new and the greenest possible

form addnewrecord
function beforeupdate

global $conn;
$strSQLExists = "select * from price_list where codigo='".$values["Code"]."'";
$rsExists = db_query($strSQLExists,$conn);
// if record exists send 2 values from query completing the fields and inform success

$strSQLInsert= ("insert _orders (Description, Price) VALUES ('".$data["Item"]."', '".$data["Unit_price"]."')");

$message="Updated ".$data["Item"].$data["Unit_price"];

foreach($values as $field=>$value)
$message.= $field." : ".$value."\r\n";
// if dont exist do something else

$message="There is No ";

foreach($values as $field=>$value)
$message.= $field." : ".$value."\r\n";


return true;

Problem, instead of

xx!0012!ipsum alori¦00000010¦£10.00

00!0000!ipsum alori¦00000000¦£10.00
xx!0012! ¦00000010¦£00.00

Stoopid hey?

  2. Re: Insert   Reply   Report abuse  
William Lang - 2008-08-01 13:08:02 - In reply to message 1 from Jose Gomes
You'll wanna use the UPDATE command instead of INSERT when updating rows.

  3. Re: Insert   Reply   Report abuse  
Jose Gomes - 2008-08-01 13:49:26 - In reply to message 1 from Jose Gomes
It seems to me that update command needs a different approach. I think I would have to go round the strategy.
I wanted to close the addnew form with two more values to complete the record update.
But I am happy to use the update command, only I cannot think how.

Thank you

  4. Re: Insert   Reply   Report abuse  
Jose Gomes - 2008-08-17 15:31:33 - In reply to message 3 from Jose Gomes
Here is

$strSQLInsert= ("UPDATE _orders SET Description='".$data["Item"]."', Price='".$data["Unit_price"]."' where code='".$data["Code"]."'");

It only updates the record in an afterUpdate Event

In beforeUpdate it doesn't work