This topic is locked

Complicated problem beyond my knowledge....

12/12/2007 2:16:33 AM
PHPRunner General questions
R
run4sbc author

Hey guys,
I've been working on a big project that has pushed my limits of coding in the first place, everything is working great and I love everything you guys have done but I've got a problem above my head again...
I have a "Master" form I use so I can enter 4 records into an "Individual" table at one time. It works great and this is the codes for that...
// Parameters:

// $values - Array object.

// Each field on the Add form is represented as a 'Field name'-'Field value' pair
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into _ArkansasInviteIndividual (EventType, LastName, FirstName, Gender, TeamCode, TeamName, SchoolYear, EventCode, EntryMark, EventMeasure, RegNum, UserID, TimeModified) values ('" . $values["EventType"]. "','" . $values["LastName"]. "','" . $values["FirstName"]. "','" . $values["Gender"]. "','" . $values["TeamCode"]. "','" . $values["TeamName"]. "','" . $values["SchoolYear"]. "','" . $values["EventCode"]. "','" . $values["EntryMark"]. "','" . $values["EventMeasure"]. "','" . $values["RegNum"]. "','" . $values["UserID"]. "','" . $values["TimeModified"] . "')";

db_exec($strSQLInsert,$conn);
global $conn;

$strSQLInsert = "insert into _ArkansasInviteIndividual (EventType, LastName, FirstName, Gender, TeamCode, TeamName, SchoolYear, EventCode, EntryMark, EventMeasure, RegNum, UserID, TimeModified) values ('" . $values["EventType"]. "','" . $values["LastName"]. "','" . $values["FirstName"]. "','" . $values["Gender"]. "','" . $values["TeamCode"]. "','" . $values["TeamName"]. "','" . $values["SchoolYear"]. "','" . $values["EventCode2"]. "','" . $values["EntryMark2"]. "','" . $values["EventMeasure"]. "','" . $values["RegNum"]. "','" . $values["UserID"]. "','" . $values["TimeModified"] . "')";

db_exec($strSQLInsert,$conn);
global $conn;

$strSQLInsert = "insert into _ArkansasInviteIndividual (EventType, LastName, FirstName, Gender, TeamCode, TeamName, SchoolYear, EventCode, EntryMark, EventMeasure, RegNum, UserID, TimeModified) values ('" . $values["EventType"]. "','" . $values["LastName"]. "','" . $values["FirstName"]. "','" . $values["Gender"]. "','" . $values["TeamCode"]. "','" . $values["TeamName"]. "','" . $values["SchoolYear"]. "','" . $values["EventCode3"]. "','" . $values["EntryMark3"]. "','" . $values["EventMeasure"]. "','" . $values["RegNum"]. "','" . $values["UserID"]. "','" . $values["TimeModified"] . "')";

db_exec($strSQLInsert,$conn);
global $conn;

$strSQLInsert = "insert into _ArkansasInviteIndividual (EventType, LastName, FirstName, Gender, TeamCode, TeamName, SchoolYear, EventCode, EntryMark, EventMeasure, RegNum, UserID, TimeModified) values ('" . $values["EventType"]. "','" . $values["LastName"]. "','" . $values["FirstName"]. "','" . $values["Gender"]. "','" . $values["TeamCode"]. "','" . $values["TeamName"]. "','" . $values["SchoolYear"]. "','" . $values["EventCode4"]. "','" . $values["EntryMark4"]. "','" . $values["EventMeasure"]. "','" . $values["RegNum"]. "','" . $values["UserID"]. "','" . $values["TimeModified"] . "')";

db_exec($strSQLInsert,$conn);
return true;
// return true if you like to proceed with adding new record

// return false otherwise
Now, my problem is that is EventCode2, EventCode3 and EventCode4 are blank I dont want them to insert. I know theres probably an IF statement I could insert into the events but I dont know the first place to start looking. If any of you had an idea, or a link to a site that could further explain this to me that'd be amazing.
Thanks so much for all your hard work!!
Cody

R
run4sbc author 12/12/2007

I've been trying to hide Null records with the SQL Query, I've tried it a million different ways and cant get it to work either.
I figured this was the best fix if I would stop the insert of blank records...
Heres the last code I tried....I tried it alot of different ways before this too, so I'm not sure what I'm doing wrong.
select `EventType`,

`LastName`,

`FirstName`,

`Initial`,

`Gender`,

`Birthdate`,

`TeamCode`,

`TeamName`,

`AgeCompNum`,

`SchoolYear`,

`EventCode`,

`EntryMark`,

`EventMeasure`,

`Division`,

`FinishPlace`,

`DeclarationStatus`,

`EntryNote`,

`RegNum`,

`EntryID`,

`UserID`,

`TimeModified`,

`MiscField`

From `_ArkansasInviteIndividual`

where (EventCode is NOT NULL)

J
Jane 12/12/2007

Hi,
try to use this code:

global $conn;

if ($values["EventCode2"])

{

$strSQLInsert = "insert into _ArkansasInviteIndividual (EventType, LastName, FirstName, Gender, TeamCode, TeamName, SchoolYear, EventCode, EntryMark, EventMeasure, RegNum, UserID, TimeModified) values ('" . $values["EventType"]. "','" . $values["LastName"]. "','" . $values["FirstName"]. "','" . $values["Gender"]. "','" . $values["TeamCode"]. "','" . $values["TeamName"]. "','" . $values["SchoolYear"]. "','" . $values["EventCode2"]. "','" . $values["EntryMark2"]. "','" . $values["EventMeasure"]. "','" . $values["RegNum"]. "','" . $values["UserID"]. "','" . $values["TimeModified"] . "')";

db_exec($strSQLInsert,$conn);

}

R
run4sbc author 12/12/2007

that worked great....sorry I'm such a n00b and didnt think of that. I kept making it seem really hard, of course that was at like 2am after I'd been working on it too long lol.
Thanks a bunch!!