This topic is locked

Check if field = null and populate populate counter

9/27/2007 9:51:48 AM
PHPRunner General questions
L
Lisa2006 author

Please help....
I have 2 tables:
Table 1: suppliers

Table 2: supplier_info
This is what I want to achieve. Users goes to the EDIT page via the suppliers table and enters there company information.

At this point the supplier_info table is blank. When the users clicks SAVE, data is populated to the new table supplier_info.
Should the user go back to the EDIT pages and amend there personnel information and click SAVE, I do not want the supplier_info table to be populated with duplicate records.
Here's the code:
global $conn;
if ($values["checkpopulate"] == null){
$strSQLInsert = "insert into supplier_info (email, company, country) values('".$values["email"]."','".$values["company"]."', 'Germany')";

db_exec($strSQLInsert,$conn);
$strSQLInsert = "insert into supplier_info (email, company, country) values('".$values["email"]."','".$values["company"]."', 'France')";

db_exec($strSQLInsert,$conn);
$strSQLInsert = "insert into supplier_info (email, company, country) values('".$values["email"]."','".$values["company"]."', 'Sweden')";

db_exec($strSQLInsert,$conn);
}else{

($values["checkpopulate"] = "1");

}
return true;
I have managed to populate the supplier_info table when the user clicks SAVE via the Supplier EDIT page. Initially, the checkpopulate field is set to NULL. However, i cannot get the logged in users field checkpopulate to be updated to 1.
Please Help and thanks in advance
Lisa

J
Jane 9/28/2007

Lisa,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

L
Lisa2006 author 9/28/2007

Lisa,

it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

L
Lisa2006 author 9/28/2007

I have uploaded files to demo account
removed link
Look forward to your response
Lisa

J
Jane 9/28/2007

Lisa,
try to use this code:

global $conn;

if ($oldvalues["checkpopulate"]== null)

{

$strSQLInsert = "insert into supplier_info (email, company, country) values('".$values["email"]."','".$values["company"]."', 'Germany')";

db_exec($strSQLInsert,$conn);
$strSQLInsert = "insert into supplier_info (email, company, country) values('".$values["email"]."','".$values["company"]."', 'France')";

db_exec($strSQLInsert,$conn);
$strSQLInsert = "insert into supplier_info (email, company, country) values('".$values["email"]."','".$values["company"]."', 'Sweden')";

db_exec($strSQLInsert,$conn);

$values["checkpopulate"] = "1";

}

else

{

$values["checkpopulate"] = "1";

}

return true;

L
Lisa2006 author 9/28/2007

Lisa,

try to use this code:

L
Lisa2006 author 9/28/2007

Jane,
Thanks a million ..... work 100%
Can you please remove demo database link from posting
Lisa

L
Lisa2006 author 10/1/2007

Following on from my original request, I have the following problem.

  • User initially subscribes and enters there company name, address, tel, etc.

    For the sake of arguement:

    Company Name: Germany Transport

    Other fields, blah blah.
    User then clicks SAVE and see's via the supplier table Ajax link company name, import, export, etc. info.
    Should the user click Edit again to edit the Company Name, say for example Germany Freight, then the supplier table Company Name info is updated to Germany Freight, however the supplier_info details is no longer available.
    My problems is that i do not know how to update the supplier_info records created via the the supplier table.
    Your help would be much appreciated.
    New Link to Demo Account: http://demo.asprunner.net/lisaham2006%5Fya.../su13/login.php
    Thank You
    Lisa

J
Jane 10/2/2007

Lisa,
answered in your personal email.