This topic is locked
[SOLVED]

 Check to see if record exists in table using unique with multiple columns

1/5/2020 8:43:25 AM
PHPRunner General questions
M
Mr Foxx author

Seeking some assistance please.

I have inserted a custom button that will add selected records to another table but the table needs to be checked for existing records.

The unique key constraint utilizes 3 fields however; studentid, current_year and subject. So there should be a check on these three columns.

Below are the codes i tried but don't seem to work.

Some help will be greatly appreciated.

Thanks in advance!
$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."" );
while($CustRecord = $button->getNextSelectedRecord())

{

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."" );

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){

$ResultDetail .= "<tr> <td>&nbsp;".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;Record already exists.</td> </tr>";

}ELSE{

//record does not exists. Add it.

DB_Exec("insert into customer_two (studentid, first_name, last_name)

values (".$CustRecord["studentid"].", '".$CustRecord["last_name"]."', '".$CustRecord["first_name"]."')");

$ResultDetail .= "<tr> <td>&nbsp;".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;Record Added.</td> </tr>";

}

}

$result["result"] = $ResultHead.$ResultDetail.$ResultFooter;

G
Grdimitris 1/5/2020

Check this

while($CustRecord = $button->getNextSelectedRecord())

{

$sql="insert into customer_two (studentid, first_name, last_name) values (".$CustRecord["studentid"].", '".$CustRecord["last_name"]."', '".$CustRecord["first_name"]."')";

$sql.="WHERE NOT EXISTS ( select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"].") LIMIT 1";

$success =DB_Exec($sql);

if (!$success)

{

$ResultDetail .= "<tr> <td>&nbsp;".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;Record already exists.</td> </tr>";

}ELSE{

//record does not exists. Add it.

$ResultDetail .= "<tr> <td>&nbsp;".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;Record Added.</td> </tr>";

}

}

$result["result"] = $ResultHead.$ResultDetail.$ResultFooter;

M
Mr Foxx author 1/6/2020

Thanks for the response. I am pulling my hair out on this one but I just can't get it to work.

Any additional help will be well appreciated.
Just to explain a little further I have two tables "Student_Reg" and "Subject_Marks"

Student_Reg fields - studentid(PrimaryKey), first_name, last_name, Sex, present_form, Repeater, Current_Year and Subject

Subject_Marks fields - record_number(Primary Key),studentid, first_name, last_name, Sex, Form, Repeater, School_Yr, Subject
I would like to select multiple records using check boxes on the list Student_Reg list page and insert into Subject_Marks

I would like to check if records exist in Subject_Marks on a unique key of three columns (studentid, School_Yr and Subject)

If the records exist an error should be displayed saying the record/s already exist

If they don't exist then the records should be added.
This is what I tried after modifying my codes to look like what you have but it still doesn't work.


//ResultTable Header

$ResultHead = "<table border='1' cellpadding='4' cellspacing='0' width='100%'><tbody>

<tr> <td>&nbsp;StudentID</td> <td>&nbsp;First Name</td> <td>&nbsp;Last Name</td> <td>&nbsp;Result</td> </tr>";

//ResultTable Footer

$ResultFooter = "</tbody></table>";
//ResultTable Detail

$ResultDetail = "";

while($CustRecord = $button->getNextSelectedRecord())

{

$sql="insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater, School_Yr, Subject) values (".$CustRecord["studentid"].", '".$CustRecord["first_name"]."', '".$CustRecord["last_name"]."', '".$CustRecord["Sex"]."', '".$CustRecord["present_form"]."', '".$CustRecord["Repeater"]."', '".$CustRecord["Current_Year"]."', '".$CustRecord["Subject"]."')";

$sql.="WHERE NOT EXISTS ( select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"].") LIMIT 1";

$success =DB_Exec($sql);

if (!$success)

{

$ResultDetail .= "<tr> <td>&nbsp;".$CustRecord["studentid"]."</td> <td>&nbsp;

".$CustRecord["first_name"]."</td> <td>&nbsp;".$CustRecord["last_name"]."</td> <td>&nbsp;Records Added.</td> </tr>";

}ELSE{

//record does not exists. Add it.

$ResultDetail .= "<tr> <td>&nbsp; ".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;".$CustRecord["last_name"]."</td> <td>&nbsp;Record Already Exists</td> </tr>";

}

}

$result["result"] = $ResultHead.$ResultDetail.$ResultFooter;

A
acpan 1/6/2020

Your SQL insert with WHERE NOT EXIST is wrong. You try to insert data to marks table where the id does not exist in the mark table, this has no logic.
We use "WHERE NOT EXIST" in a SELECT SQL statement to limit the result. NOT directly for a insert command. i.e. "INSERT ..... WHERE NOT EXIST" is wrong syntax.
INSERT syntax:
INSERT INTO table_name

VALUES (value1, value2, value3, ...);
SELECT syntax with WHERE NOT EXIST condition to limit the list:
SELECT * FROM (SELECT 'name1', 'add', '022') AS tmp

WHERE NOT EXISTS (

SELECT name FROM table_listnames WHERE name = 'name1'

);
Combine them to one insert:
INSERT INTO table_listnames (name, address, tele) values

SELECT name, address, tele FROM tmp1

WHERE NOT EXISTS (

SELECT name FROM table_listnames WHERE name = 'name1'

);
In your case, you should not use INSERT values (SELECT ... WHERE NOT EXIST), because the select statement is not the params for the insert, you are not pulling the values from the select and give the values as parameters to the insert command.
I think you should echo out the values in stages and show the values here. You just mentioned it does not work, whole block of codes does not work and don't know why, so best is break it down and see what the values are and the SQL strings in each stage.

  1. Check and echo out the records selected. $button->getNextSelectedRecord()) should give you an array, print_r the array or echo json_encode the array.
  2. Then check if the records exist in the student marks table. Again echo out the result and the SQL command you use to check.
  3. Finally insert if not found.
    ACP

M
Mr Foxx author 1/6/2020

Thanks for responding.
The codes posted last was modified based on suggestions by Grdimitris.
My original codes are listed below. They work fine but only if I check if the records exist on a single field. Once I try testing on the three fields studentid, School_Yr and Subject then they don't work.
I just need some help adjusting the code below to make them work.
Thanks again!



//ResultTable Header

$ResultHead = "<table border='1' cellpadding='4' cellspacing='0' width='100%'><tbody>

<tr> <td>&nbsp;StudentID</td> <td>&nbsp;First Name</td> <td>&nbsp;Last Name</td> <td>&nbsp;Result</td> </tr>";
//ResultTable Footer

$ResultFooter = "</tbody></table>";
//ResultTable Detail

$ResultDetail = "";
//Loop trough all selected records

while($CustRecord = $button->getNextSelectedRecord())

{

// See if record exists.

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){

//record already exists.

$ResultDetail .= "<tr> <td>&nbsp; ".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;".$CustRecord["last_name"]."</td> <td>&nbsp;Record already exists.</td> </tr>";
}ELSE{

//record does not exists. Add it.

DB_Exec("insert into Subject_Marks(studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject)

values (".$CustRecord["studentid"].", '".$CustRecord["first_name"]."', '".$CustRecord["last_name"]."','".$CustRecord["Sex"]."','".$CustRecord["present_form"]."','".$CustRecord["Repeater"]."', '".$CustRecord["Current_Year"]."','".$CustRecord["Subject"]."')");

$ResultDetail .= "<tr> <td>&nbsp; ".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;".$CustRecord["last_name"]."</td> <td>&nbsp;Record Added.</td> </tr>";

}

}

$result["result"] = $ResultHead.$ResultDetail.$ResultFooter;

A
acpan 1/6/2020

Your codes can definitely be simplified and values printed to debug when facing problem like this.

You are posting a chunk of codes without output values, which is hard to comment unless physically try out on our own PC.
Anyway, this will work (recreated and verified on my PC):
In Server Event:



$debug = ""; $debugSQL =""; $record_added = ""; $record_skipped = "";
$insert_fields =" insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES ";

$insert_values = "";
while($CustRecord = $button->getNextSelectedRecord())

{

$studentid = $CustRecord["studentid"];

$School_Yr = $CustRecord["Current_Year"];

$Subject = $CustRecord["Subject"];

$Repeater = $CustRecord["Repeater"];

$first_name = $CustRecord["first_name"];

$last_name = $CustRecord["last_name"];

$Form = $CustRecord["present_form"];

$Sex = $CustRecord["Sex"];
$strSQL = "SELECT record_number from Subject_Marks WHERE studentid = $studentid

AND School_Yr = '$School_Yr' AND Subject = '$Subject'";



$debugSQL .= "Check SQL: $strSQL ";

$rs = DB::Query($strSQL);

$data=$rs->fetchAssoc();
if($data)

{

$record_skipped .= " (Student ID:$studentid, Year:$School_Yr, Subject:$Subject) |";

}

else

{

$record_added .= " (Student ID:$studentid, Year:$School_Yr, Subject:$Subject) |";

$insert_values .= " ($studentid, '$first_name', '$last_name', '$Sex', '$Form', '$Repeater','$School_Yr', '$Subject'), ";

}
} // end while
if ( strlen($record_skipped) > 0 )

{

$record_skipped = "Record(s) skipped: ".rtrim(trim($record_skipped), "|");

}

else

{

$record_skipped = "0 record skipped";

}
if ( strlen($record_added) > 0 )

{

$record_added = "Record(s) added: ".rtrim(trim($record_added), "|");

}

else

{

$record_added = "0 record added";

}
if ( strlen($insert_values) > 0 )

{

$insert_values = rtrim(trim($insert_values), ",");



$strSQL = $insert_fields.$insert_values;

$debugSQL .= " | Insert SQL: $strSQL ";

$insert_result = DB::Exec($strSQL);

if ($insert_result)

{

$message = "Record Inserted!";

}

else

{

$message = "Insert Failed!";

}

}

else

{

$message = "No Record Selected";

$debugSQL .= " | Insert SQL: Nothing to insert! ";

}
$result['sql'] = $debugSQL;

$result['records_added'] = $record_added;

$result['records_skipped'] = $record_skipped;

$result['debug'] = $debug;

$result['message'] = $message;


In Client After Event:



// Choose what to print out:
// var message = result['message'];

// ajax.setMessage(message);
// var debug = result['sql'] + result['debug'];

// ajax.setMessage(debug);
var record_performed = result['records_added'] + "
" + result['records_skipped'];

ajax.setMessage(record_performed);
M
Mr Foxx author 1/6/2020



Your codes can definitely be simplified and values printed to debug when facing problem like this.

You are posting a chunk of codes without output values, which is hard to comment unless physically try out on our own PC.
Anyway, this will work (recreated and verified on my PC):
In Server Event:



$debug = ""; $debugSQL =""; $record_added = ""; $record_skipped = "";
$insert_fields =" insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES ";

$insert_values = "";
while($CustRecord = $button->getNextSelectedRecord())

{

$studentid = $CustRecord["studentid"];

$School_Yr = $CustRecord["Current_Year"];

$Subject = $CustRecord["Subject"];

$Repeater = $CustRecord["Repeater"];

$first_name = $CustRecord["first_name"];

$last_name = $CustRecord["last_name"];

$Form = $CustRecord["present_form"];

$Sex = $CustRecord["Sex"];
$strSQL = "SELECT record_number from Subject_Marks WHERE studentid = $studentid

AND School_Yr = '$School_Yr' AND Subject = '$Subject'";
$debugSQL .= "Check SQL: $strSQL ";

$rs = DB::Query($strSQL);

$data=$rs->fetchAssoc();
if($data)

{

$record_skipped .= " (Student ID:$studentid, Year:$School_Yr, Subject:$Subject) |";

}

else

{

$record_added .= " (Student ID:$studentid, Year:$School_Yr, Subject:$Subject) |";

$insert_values .= " ($studentid, '$first_name', '$last_name', '$Sex', '$Form', '$Repeater','$School_Yr', '$Subject'), ";

}
} // end while
if ( strlen($record_skipped) > 0 )

{

$record_skipped = "Record(s) skipped: ".rtrim(trim($record_skipped), "|");

}

else

{

$record_skipped = "0 record skipped";

}
if ( strlen($record_added) > 0 )

{

$record_added = "Record(s) added: ".rtrim(trim($record_added), "|");

}

else

{

$record_added = "0 record added";

}
if ( strlen($insert_values) > 0 )

{

$insert_values = rtrim(trim($insert_values), ",");
$strSQL = $insert_fields.$insert_values;

$debugSQL .= " | Insert SQL: $strSQL ";

$insert_result = DB::Exec($strSQL);

if ($insert_result)

{

$message = "Record Inserted!";

}

else

{

$message = "Insert Failed!";

}

}

else

{

$message = "No Record Selected";

$debugSQL .= " | Insert SQL: Nothing to insert! ";

}
$result['sql'] = $debugSQL;

$result['records_added'] = $record_added;

$result['records_skipped'] = $record_skipped;

$result['debug'] = $debug;

$result['message'] = $message;


In Client After Event:



// Choose what to print out:
// var message = result['message'];

// ajax.setMessage(message);
// var debug = result['sql'] + result['debug'];

// ajax.setMessage(debug);
var record_performed = result['records_added'] + "
" + result['records_skipped'];

ajax.setMessage(record_performed);



Very appreciative of this acpan, however, after building my project whenever the button to copy the records is clicked nothing happens. Not even error, nothing at all.

I'm not sure if there is something additional to be done.
Thanks

A
acpan 1/6/2020

The codes are verified working on my PC.
You can put this in the app init:
if ($_REQUEST["debug"]=="true")

$dDebug=true;
Then: add debug=true to your URL in the address bar:
your_url.php?debug=true
you may see some debug message on your screen, may help to see if there is other error.
ACP

A
acpan 1/6/2020

Other things to check: check if there is error from Chrome developer console, may be you miss a ; or some cut and paste wrongly issue.
ACP

M
Mr Foxx author 1/6/2020



The codes are verified working on my PC.
You can put this in the app init:
if ($_REQUEST["debug"]=="true")

$dDebug=true;
Then: add debug=true to your URL in the address bar:
your_url.php?debug=true
you may see some debug message on your screen, may help to see if there is other error.
ACP


Where exactly do I place these codes?

if ($_REQUEST["debug"]=="true")

$dDebug=true;

A
acpan 1/6/2020

Go to events, After application init to insert the debug.
I have copied the codes posted here and pasted back to my phprunner and generated, it works, so the codes posted are confirmed okay.

Unless, the fields names or data types are different to your own table, if any.
Here's the screencast:



ACP

M
Mr Foxx author 1/6/2020



Go to events, After application init to insert the debug.
I have copied the codes posted here and pasted back to my phprunner and generated, it works, so the codes posted are confirmed okay.

Unless, the fields names or data types are different to your own table, if any.
Here's the screencast:



ACP


There is no error displayed.

I even tried inserting a new button but still doesn't work.
if i try this simple codes it works flawlessly

global $dal;

while ( $data = $button->getNextSelectedRecord() )

{

$sql = "INSERT IGNORE INTO Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater, school_yr, Subject) values ('".$data["studentid"]."', '".$data["first_name"]."', '".$data["last_name"]."','".$data["Sex"]."', '".$data["present_form"]."', '".$data["Repeater"]."', '".$data["Current_Year"]."', '".$data["Subject"]."')";

CustomQuery($sql);

}

$result["txt"] = "Records Added";

A
acpan 1/6/2020

This shows you have SQL error.
INSERT IGNORE statement, the rows with invalid data that cause the error are ignored and the rows with valid data are inserted into the table. (Using IGNORE is not advisable for production as the data inserted is unpredictable)

  1. You may have fields that are not supposed to be empty.
  2. You may have invalid data (eg. data type mismatch. string type insert as numberic without quotes, check your table field data types and field names properly, see why it is important to log the $debugSQL in the codes i pasted)
    If you can log the SQL commands (which i suggested to you) and run manually in an SQL editor, it will show you where the error is.
    ACP

M
Mr Foxx author 1/6/2020



Where exactly do I place these codes?

if ($_REQUEST["debug"]=="true")

$dDebug=true;


No messages came up after i did this

A
acpan 1/6/2020

Lastly, just give you another way to see what SQL command is executed:
Save the two SQL commands to a session name and show it in the list page:
in your Server Event:
// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;
In before display event:
echo "

SQL Check: ".$_SESSION["sql1"];

echo "

SQL Insert: ".$_SESSION["sql2"];
Refresh your list page and see if the commands are printed.
And copy the command and run it manually from the SQL editor and see what errors are shown.
ACP

A
acpan 1/6/2020

I already spotted one error by a casual glance:
My Command:
$strSQL = "SELECT record_number from Subject_Marks WHERE studentid = $studentid

AND School_Yr = '$School_Yr' AND Subject = '$Subject'";
your command:
$sql = "INSERT IGNORE INTO Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater, school_yr, Subject) values ('".$data["studentid"]."', '".$data["first_name"]."', '".$data["last_name"]."','".$data["Sex"]."', '".$data["present_form"]."', '".$data["Repeater"]."', '".$data["Current_Year"]."', '".$data["Subject"]."')";
The different:
School_Yr vs school_yr
You are causing problem for yourself by having fields in inconsistent lower and upper cases all over.

I followed one of your message and created the fields. But it seems you name your field names inconsistently lower and upper cases.
SELECT IGNORE works "flawlessly" because it just don't care about any errors and insert for you. Dangerous!
ACP



There is no error displayed.

I even tried inserting a new button but still doesn't work.
if i try this simple codes it works flawlessly

global $dal;

while ( $data = $button->getNextSelectedRecord() )

{

$sql = "INSERT IGNORE INTO Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater, school_yr, Subject) values ('".$data["studentid"]."', '".$data["first_name"]."', '".$data["last_name"]."','".$data["Sex"]."', '".$data["present_form"]."', '".$data["Repeater"]."', '".$data["Current_Year"]."', '".$data["Subject"]."')";

CustomQuery($sql);

}

$result["txt"] = "Records Added";

M
Mr Foxx author 1/6/2020



Lastly, just give you another way to see what SQL command is executed:
Save the two SQL commands to a session name and show it in the list page:
in your Server Event:
// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;
In before display event:
echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];
Refresh your list page and see if the commands are printed.
And copy the command and run it manually from the SQL editor and see what errors are shown.
ACP


I get this error when attempting to load the pages:

Parse error: syntax error, unexpected '>' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php on line 124

A
acpan 1/6/2020

You give another command:
$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."" );
Notice: School_Yr is Upper case, and then you used lower case in other place.

A
acpan 1/6/2020

>I get this error when attempting to load the pages:

>Parse error: syntax error, unexpected '>' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php >on line 124

>[/quote]
The error and line is shown, go get the bug.
That's all i can help, you should look through carefully all your casual mistakes, i think you don't follow exactly your database field names to create your SQL commands.

M
Mr Foxx author 1/6/2020



>I get this error when attempting to load the pages:

>Parse error: syntax error, unexpected '>' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php >on line 124

>


The error and line is shown, go get the bug.
That's all i can help, you should look through carefully all your casual mistakes.

[/quote]
This is the error:
*<?php
/**

  • Dear developer!
  • Never modify events.php file, it is autogenerated.
  • Modify PHP/EventTemplates/events.txt instead.



    /
    class eventclass_Student_Reg extends eventsBase

    {

    function __construct()

    {

    // fill list of events
    $this->events["BeforeShowList"]=true;
    }
    // handlers


A
acpan 1/6/2020

error is in Student_Reg_events.php line 124, but you are giving events.php?



The error and line is shown, go get the bug.
That's all i can help, you should look through carefully all your casual mistakes.


This is the error:
*<?php
/**

  • Dear developer!
  • Never modify events.php file, it is autogenerated.
  • Modify PHP/EventTemplates/events.txt instead.



    /
    class eventclass_Student_Reg extends eventsBase

    {

    function __construct()

    {

    // fill list of events
    $this->events["BeforeShowList"]=true;
    }
    // handlers

    *

    [/quote]

M
Mr Foxx author 1/6/2020



Your codes can definitely be simplified and values printed to debug when facing problem like this.

You are posting a chunk of codes without output values, which is hard to comment unless physically try out on our own PC.
Anyway, this will work (recreated and verified on my PC):
In Server Event:



$debug = ""; $debugSQL =""; $record_added = ""; $record_skipped = "";
$insert_fields =" insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES ";

$insert_values = "";
while($CustRecord = $button->getNextSelectedRecord())

{

$studentid = $CustRecord["studentid"];

$School_Yr = $CustRecord["Current_Year"];

$Subject = $CustRecord["Subject"];

$Repeater = $CustRecord["Repeater"];

$first_name = $CustRecord["first_name"];

$last_name = $CustRecord["last_name"];

$Form = $CustRecord["present_form"];

$Sex = $CustRecord["Sex"];
$strSQL = "SELECT record_number from Subject_Marks WHERE studentid = $studentid

AND School_Yr = '$School_Yr' AND Subject = '$Subject'";
$debugSQL .= "Check SQL: $strSQL ";

$rs = DB::Query($strSQL);

$data=$rs->fetchAssoc();
if($data)

{

$record_skipped .= " (Student ID:$studentid, Year:$School_Yr, Subject:$Subject) |";

}

else

{

$record_added .= " (Student ID:$studentid, Year:$School_Yr, Subject:$Subject) |";

$insert_values .= " ($studentid, '$first_name', '$last_name', '$Sex', '$Form', '$Repeater','$School_Yr', '$Subject'), ";

}
} // end while
if ( strlen($record_skipped) > 0 )

{

$record_skipped = "Record(s) skipped: ".rtrim(trim($record_skipped), "|");

}

else

{

$record_skipped = "0 record skipped";

}
if ( strlen($record_added) > 0 )

{

$record_added = "Record(s) added: ".rtrim(trim($record_added), "|");

}

else

{

$record_added = "0 record added";

}
if ( strlen($insert_values) > 0 )

{

$insert_values = rtrim(trim($insert_values), ",");
$strSQL = $insert_fields.$insert_values;

$debugSQL .= " | Insert SQL: $strSQL ";

$insert_result = DB::Exec($strSQL);

if ($insert_result)

{

$message = "Record Inserted!";

}

else

{

$message = "Insert Failed!";

}

}

else

{

$message = "No Record Selected";

$debugSQL .= " | Insert SQL: Nothing to insert! ";

}
$result['sql'] = $debugSQL;

$result['records_added'] = $record_added;

$result['records_skipped'] = $record_skipped;

$result['debug'] = $debug;

$result['message'] = $message;


In Client After Event:



// Choose what to print out:
// var message = result['message'];

// ajax.setMessage(message);
// var debug = result['sql'] + result['debug'];

// ajax.setMessage(debug);
var record_performed = result['records_added'] + "
" + result['records_skipped'];

ajax.setMessage(record_performed);



I think there's a little misunderstanding.

This is the exact code i'm using.

A
acpan 1/6/2020

Check all your database field names with the SQL commands, because you gave different upper and lower cases in different messages and i created based on one of your messages. it could be not matching your actual database, it must be exact and your naming convention is not consistent, try to use all lowercase for php and database table names and fields in future.



I think there's a little misunderstanding.

This is the exact code i'm using.

A
acpan 1/6/2020

My tables created based on one of your messages:
Subject_Marks
record_number int(11)

studentid int(11)

first_name char(50)

last_name char(50)

Sex char(5)

School_Yr char(10)

Subject char(50)

Form char(10)

Repeater char(10)
Student_Reg
studentid int(11)

first_name char(100)

last_name char(100)

Sex char(5)

present_form char(10)

Repeater char(10)

Current_Year char(10)

Subject char(50)
Check through your own tables. If you want to use my codes, your tables names and field names must match exactly my tables names and their field names. you should use all lower case in future.

M
Mr Foxx author 1/6/2020



My tables created based on one of your message:
Subject_Marks
record_number int(11)

studentid int(11)

first_name char(50)

last_name char(50)

Sex char(5)

School_Yr char(10)

Subject char(50)

Form char(10)

Repeater char(10)
Student_Reg
studentid int(11)

first_name char(100)

last_name char(100)

Sex char(5)

present_form char(10)

Repeater char(10)

Current_Year char(10)

Subject char(50)
Check through your own tables. If you want to use my codes, your tables names and field names must match exactly my tables field names.


Subject_Marks (

record_number int(11) NOT NULL,

studentid int(10) NOT NULL,

first_name varchar(25) DEFAULT NULL,

last_name varchar(25) DEFAULT NULL,

Sex varchar(6) DEFAULT NULL,

Form varchar(5) DEFAULT NULL,

Repeater varchar(3) DEFAULT NULL,

School_Yr varchar(15) DEFAULT NULL,

Subject varchar(35) NOT NULL,

MicLetGrade varchar(3) DEFAULT NULL,

HilLetGrade varchar(3) DEFAULT NULL,

TrinLetGrade varchar(3) DEFAULT NULL,

MicMark int(11) DEFAULT NULL,

MicGrade varchar(3) DEFAULT NULL,

HilMark int(11) DEFAULT NULL,

HilGrade varchar(3) DEFAULT NULL,

TrinTerm int(11) DEFAULT NULL,

AllTermsAv int(11) DEFAULT NULL,

TrinExam int(11) DEFAULT NULL,

TrinTotal int(11) DEFAULT NULL,

TrinGrade varchar(3) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Student_Reg (

studentid int(10) NOT NULL,

first_name varchar(25) NOT NULL DEFAULT '',

last_name varchar(25) NOT NULL DEFAULT '',

Sex varchar(6) NOT NULL DEFAULT '',

present_form varchar(5) NOT NULL DEFAULT '',

Repeater varchar(3) DEFAULT NULL,

Current_Year varchar(15) DEFAULT NULL,

Subject varchar(35) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

A
acpan 1/6/2020

Tables looks matched with the fields name. your Subject_Marks table, record_number, i hope you have set auto-increment because it is set as NOT NULL, without auto-increment, insert to the Subject_Marks table will give errors.

M
Mr Foxx author 1/6/2020



Tables looks matched with the fields name. your Subject_Marks table, record_number, i hope you have set auto-increment because it is set as NOT NULL, without auto-increment, insert to the Subject_Marks table will give errors.


Yes it is

A
acpan 1/6/2020

You need to print out the sql commands and run manually and see the errors.
Once you get the command and run it manually, paste here so that we can have a look.
ACP

M
Mr Foxx author 1/6/2020



Lastly, just give you another way to see what SQL command is executed:
Save the two SQL commands to a session name and show it in the list page:
in your Server Event:
// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;
In before display event:
echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];
Refresh your list page and see if the commands are printed.
And copy the command and run it manually from the SQL editor and see what errors are shown.
ACP


when I try this no commands are printed just the error I showed earlier

A
acpan 1/6/2020

By the way, which phprunner version are yiu using?

M
Mr Foxx author 1/6/2020



By the way, which phprunner version are yiu using?



10.3

lefty 1/6/2020



Lastly, just give you another way to see what SQL command is executed:
Save the two SQL commands to a session name and show it in the list page:
in your Server Event:
// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;
In before display event:
echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];
Refresh your list page and see if the commands are printed.
And copy the command and run it manually from the SQL editor and see what errors are shown.
ACP


Latest Build is 34262

M
Mr Foxx author 1/6/2020



Thanks for responding.
The codes posted last was modified based on suggestions by Grdimitris.
My original codes are listed below. They work fine but only if I check if the records exist on a single field. Once I try testing on the three fields studentid, School_Yr and Subject then they don't work.
I just need some help adjusting the code below to make them work.
Thanks again!



//ResultTable Header

$ResultHead = "<table border='1' cellpadding='4' cellspacing='0' width='100%'><tbody>

<tr> <td>&nbsp;StudentID</td> <td>&nbsp;First Name</td> <td>&nbsp;Last Name</td> <td>&nbsp;Result</td> </tr>";
//ResultTable Footer

$ResultFooter = "</tbody></table>";
//ResultTable Detail

$ResultDetail = "";
//Loop trough all selected records

while($CustRecord = $button->getNextSelectedRecord())

{

// See if record exists.

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){

//record already exists.

$ResultDetail .= "<tr> <td>&nbsp; ".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;".$CustRecord["last_name"]."</td> <td>&nbsp;Record already exists.</td> </tr>";
}ELSE{

//record does not exists. Add it.

DB_Exec("insert into Subject_Marks(studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject)

values (".$CustRecord["studentid"].", '".$CustRecord["first_name"]."', '".$CustRecord["last_name"]."','".$CustRecord["Sex"]."','".$CustRecord["present_form"]."','".$CustRecord["Repeater"]."', '".$CustRecord["Current_Year"]."','".$CustRecord["Subject"]."')");

$ResultDetail .= "<tr> <td>&nbsp; ".$CustRecord["studentid"]."</td> <td>&nbsp;".$CustRecord["first_name"]."</td> <td>&nbsp;".$CustRecord["last_name"]."</td> <td>&nbsp;Record Added.</td> </tr>";

}

}

$result["result"] = $ResultHead.$ResultDetail.$ResultFooter;


Can you tell me why if I change the above codes to this it works just fine:

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){


This is my main problem with my original codes, there seems to be a problem when checking all three columns.

lefty 1/6/2020



Lastly, just give you another way to see what SQL command is executed:
Save the two SQL commands to a session name and show it in the list page:
in your Server Event:
// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;
In before display event:
echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];
Refresh your list page and see if the commands are printed.
And copy the command and run it manually from the SQL editor and see what errors are shown.
ACP


You are trying to reference a unique ID or a field that is not available yet , that may have many to many relationships, or more than one or One of Those fields is NULL or not yet known .This not really a PHPrunner problem and does not support this type of query . You need either to use a Complex Stored Procedure in MYSQL or MSSQL or use $_SESSION values on the record or the fields you are working on to get your values by selecting the master record and saving the sessions . I just had this problem with a client and spent many hours of what you are trying to do . Don't work . Ended up using SESSION on all fields. And then unset them after server event in button. Hope this saves you some time.

lefty 1/6/2020



You are trying to reference a unique ID or a field that is not available yet , that may have many to many relationships, or more than one or One of Those fields is NULL or not yet known .This not really a PHPrunner problem and does not support this type of query . You need either to use a Complex Stored Procedure in MYSQL or MSSQL or use $_SESSION values on the record or third field you are working on to get your values by selecting the master record and saving the sessions . I just had this problem with a client and spent many hours of what you are trying to do . Don't work . Ended up using SESSION on all fields. And then unset them after server event in button. Hope this saves you some time.

lefty 1/6/2020
M
Mr Foxx author 1/7/2020



Complex Stored Procedures


Thanks for this useful tip. Unfortunately I'm a newbie and NOT very verse in this.

Can you tell me exactly what I need to do to accomplish what I'n trying to accomplish.

How to create the stored procedures for my database tables and what do I put in phprunner to call the procedure.

A
acpan 1/7/2020

Don't do a stored procedure or any other method to complicate further, when my codes with a simple SQL query already works here. I will try to avoid store procedure at all cost unless no choice for example transactional processes or batch processing in the Database Server.
It is already proven working with animated picture given, in the most simplest form of SQL commands in my earlier post. Please read it.
Read my working codes
For button codes, you need to echo out the SQL/commands and errors as suggested in this thread.

You must be able to dump out values to see. That is a must when you face problem. The codes i gave you even has debug variables for display in the after client events prepared for you, you can try it. Those are the variables i used to verify the output before i posted in this thread.
If you can't debug at all, at least, you can try to incrementally change your codes with the working codes. You cut a bit from working code and swap a bit into your old codes and see the difference bit by bit.
ACP

M
Mr Foxx author 1/7/2020



Don't do a stored procedure or any other method to complicate further, when my codes with a simple SQL query already works here. I will try to avoid store procedure at all cost unless no choice for example transactional processes or batch processing in the Database Server.
It is already proven working with animated picture given, in the most simplest form of SQL commands in my earlier post. Please read it.
Read my working codes
For button codes, you need to echo out the SQL/commands and errors as suggested in this thread.

You must be able to dump out values to see. That is a must when you face problem. The codes i gave you even has debug variables for display in the after client events prepared for you, you can try it. Those are the variables i used to verify the output before i posted in this thread.
If you can't debug at all, at least, you can try to incrementally change your codes with the working codes. You cut a bit from working code and swap a bit into your old codes and see the difference bit by bit.
ACP


Can you tell me why if I change the above codes to this it works just fine:

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){

but if I use the three columns it just doesn't work
DB_Exec("insert into Subject_Marks(studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject)

values (".$CustRecord["studentid"].", '".$CustRecord["first_name"]."', '".$CustRecord["last_name"]."','".$CustRecord["Sex"]."','".$CustRecord["present_form"]."','".$CustRecord["Repeater"]."', '".$CustRecord["Current_Year"]."','".$CustRecord["Subject"]."')");

A
acpan 1/7/2020

First, one is Select Query, to pull data out, one is insert data. You are asking why i read is okay but insert not okay. They are 2 different SQL operations. U sure you dnt know the difference? it is dangerous to mess with database with this understanding.
2nd, you can simplify your codes effortlessly by follow my example. Eg. you can replace the variables in your query.

M
Mr Foxx author 1/7/2020



First, one is Select Query, to pull data out, one is insert data. You are asking why i read is okay but insert not okay. They are 2 different SQL operations. U sure you dnt know the difference? it is dangerous to mess with database with this understanding.
2nd, you can simplify your codes effortlessly by follow my example. Eg. you can replace the variables in your query.


Sorry I pasted the wrong code. Yes I know the difference between the two <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89857&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
I meant if I use this it doesn't work:

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){
If I use this it works fine:

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){

A
acpan 1/7/2020

At this point, and this kind of error, it is exactly that you need to print out what SQL command is formed by you and executed, and run it manually from SQL editor. I have advised you many times. There is error in your SQL commands formed and you need to print it out. You just can't print out.
Just to give you a quick one, there could be no space in your " AND " when you join them in your string.
ACP



Sorry I pasted the wrong code. Yes I know the difference between the two <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89858&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
I meant if I use this it doesn't work:

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]." AND School_Yr = ".$CustRecord["Current_Year"]." AND Subject = ".$CustRecord["Subject"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){
If I use this it works fine:

$rsEx = DB::Query("select record_number from Subject_Marks where studentid = ".$CustRecord["studentid"]."");

$CustData = $rsEx->fetchNumeric();

IF(IsSet($CustData[0])){

A
acpan 1/7/2020

and there could be missing quotes for $CustRecord["Current_Year"] or some other string fields.
Earlier thread i did mention there could be data type mismatched, string, you treat it as numeric.
Check your data type
Again, such errors you need to print out the SQL command formed by you and run it manually. This kind of error could be solved in less than 5 minutes if you print out the SQL command.
ACP

M
Mr Foxx author 1/7/2020



At this point, and this kind of error, it is exactly that you need to print out what SQL command is formed by you and executed, and run it manually from SQL editor. I have advised you many times. There is error in your SQL commands formed and you need to print it out. You just can't print out.
Just to give you a quick one, there could be no space in your " AND " when you join them in your string.
ACP


Okay so i tried placing this in the server code of my button:

// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;

And this in In before display event:

*

echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];
Nothing is displayed when i build the project except this error

Parse error: syntax error, unexpected '>' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php on line 124

when i check the line this is what's there:



echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];*

A
acpan 1/7/2020

the error says >,
could cause error, remove them or replace with |
and i hope you put your session values for $strSQL at the right place and not insert anywhere. I dnt see you have $strSQL defined in your codes.

A
acpan 1/7/2020

There is error here:
echo "

SQL Check: ".$_SESSION["sql1'];

echo "

SQL Insert: ".$_SESSION["sql2'];
Should be
$_SESSION["sql1"]

$_SESSION["sql2"]
the quotes are not right, i am using mobile phone to reply so it is not easy to type. So error is not caused by

M
Mr Foxx author 1/7/2020



the error says >,
could cause error, remove them or replace with |
and i hope you put your session values for $strSQL at the right place and not insert anywhere. I dnt see you have $strSQL defined in your codes.


I placed this right below all sql codes on the server event code on the button

// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;

And this in before display even



$_SESSION["sql1"]

$_SESSION["sql2"]

Still error:

Parse error: syntax error, unexpected 'Insert' (T_STRING), expecting ']' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php on line 124

A
acpan 1/7/2020

Sorry, can tell what is in that line that causes error, without seeing the lines:
Still error:

Parse error: syntax error, unexpected 'Insert' (T_STRING), expecting ']' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php on line 124

A
acpan 1/7/2020

yes, you place below all Sql, but do you have $strSQL = "...." before that? Can't show me if you have that statement ? cut and paste to show?



I placed this right below all sql codes on the server event code on the button

// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;

And this in before display even



$_SESSION["sql1"]

$_SESSION["sql2"]

Still error:

Parse error: syntax error, unexpected 'Insert' (T_STRING), expecting ']' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php on line 124

A
acpan 1/7/2020

wait, Omg, you just pasted:
$_SESSION["sql1"]

$_SESSION["sql2"]
i asked you to correct the quotes from single quotes to double quotes, not literally paste that.
$_SESSION["sql1'] => $_SESSION["sql1"]
$_SESSION["sql2'] => $_SESSION["sql2"]



I placed this right below all sql codes on the server event code on the button

// Save the check SQL command

$_SESSION["sql1"] = $strSQL;
// SAve the Insert SQL

$_SESSION["sql2"] = $strSQL;

And this in before display even



$_SESSION["sql1"]

$_SESSION["sql2"]

Still error:

Parse error: syntax error, unexpected 'Insert' (T_STRING), expecting ']' in C:\Users\Walkie\Documents\SAASS Final\SAASS_Finalv2\output\include\Student_Reg_events.php on line 124

M
Mr Foxx author 1/7/2020



wait, Omg, you just pasted:
$_SESSION["sql1"]

$_SESSION["sql2"]
i asked you to correct the quotes from single quotes to double quotes, not literally paste that.
$_SESSION["sql1'] => $_SESSION["sql1"]
$_SESSION["sql2'] => $_SESSION["sql2"]


Sorry!!

I got this error:

SQL Check: insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES (4, 'Chuck', 'Norris', 'M', '1N', 'Yes','2017-2018', 'TD')
SQL Insert: insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES (4, 'Chuck', 'Norris', 'M', '1N', 'Yes','2017-2018', 'TD')

A
acpan 1/7/2020

Good, that's what we want to see. Run in your SQL editor, and show the errors.
By the way, SqL check should not be insert command, should be Select query. YOU ASSIGNED WRONGLY the variables.



Sorry!!

I got this error:

SQL Check: insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES (4, 'Chuck', 'Norris', 'M', '1N', 'Yes','2017-2018', 'TD')
SQL Insert: insert into Subject_Marks (studentid, first_name, last_name, Sex, Form, Repeater,School_Yr, Subject) VALUES (4, 'Chuck', 'Norris', 'M', '1N', 'Yes','2017-2018', 'TD')

A
acpan 1/7/2020

Show the Select Query, it must have missing quotes somewhere.

M
Mr Foxx author 1/7/2020



Show the Select Query, it must have missing quotes somewhere.


I think I'm making some progress. The record is actually inserted but there are no messages displayed.

Nothing to indicate what was inserted.

A
acpan 1/7/2020

magic, it works suddenly.

M
Mr Foxx author 1/7/2020



magic, it works suddenly.


I think the records were being inserted before but because I was looking for onscreen messages indicating success or failure I wasn't aware.

your codes work fine for the insert I just need some assistance with the onscreen messages now.

A
acpan 1/7/2020

I suggest you read again the codes i posted again, where after client event shows various messages to be displayed, the assistant was given there with animated screencast.



I think the records were being inserted before but because I was looking for onscreen messages indicating success or failure I wasn't aware.

your codes work fine for the insert I just need some assistance with the onscreen messages now.

lefty 1/7/2020



I suggest you read again the codes i posted again, where after client event shows various messages to be displayed, the assistant was given there with animated screencast.


If this query is just for one table , did not see that , thought it was multiple , then yes no stored procedure . Just add in events after application Initialized this one line of code ; . This will debug the whole application and you can see everything that happens with the query when you click on your button.

M
Mr Foxx author 1/7/2020



I suggest you read again the codes i posted again, where after client event shows various messages to be displayed, the assistant was given there with animated screencast.


I went through the codes over and over but i can't seem to spot the reason for the messages not displaying.

This is what i have in the button Client After:


var message = result['message'];

ajax.setMessage(message);
var debug = result['sql'] + result['debug'];

ajax.setMessage(debug);
var record_performed = result['records_added'] + "
" + result['records_skipped'];

ajax.setMessage(record_performed);

A
acpan 1/7/2020

the above code is direct copy from phprunner example without any changes.
try insert a new button and practise until you can pass message to after client events.
do until you can then understand the example given by phprunner, pass different message until you understand.
Then you try again on this.

M
Mr Foxx author 1/7/2020



the above code is direct copy from phprunner example without any changes.
try insert a new button and practise until you can pass message to after client events.
do until you can then understand the example given by phprunner, pass different message until you understand.
Then you try again on this.


Thank you very much for your time and patience. I don't seek assistance unless I have tried all that I can.
I have been at this for the past two weeks trying different things and wasn't successful and you acpan through this forum has been a life saver.
After playing around a bit I eventually used the following code in client after:
var message = result['records_added'] + "
" + result['records_skipped'];

ctrl.setMessage(message);

Again thanks for ALL the guided assistance.

A
acpan 1/7/2020

Glad u did it!
Suggested you to try the example because through trying a simple and working case, will give u confident and trigger you to fix it.
ACP

M
Mr Foxx author 1/7/2020



Glad u did it!
Suggested you to try the example because through trying a simple and working case, will give u confident and trigger you to fix it.
ACP


I even added some flare to it so that the message disappears after 9 seconds <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89881&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89881&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' /> !
var message = result['records_added'] + "
" + result['records_skipped'];

ctrl.setMessage(message);

setTimeout(function(ctrl)

{

window.location.reload();

}

, 9000);

Also because the number of recrds added can be quite numerous for the sake of space I shortened the codes for the displayed messages.
$record_skipped .= " $first_name $last_name $Subject |";

}

else

{

$record_added .= " $first_name $last_name $Subject |";

A
acpan 1/7/2020

There u go <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89882&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Hopefully, u name all your field names, table names to lowercase in future and remember how to dump out the values with the session variables and tips u picked up here.
Good luck!

M
Mr Foxx author 1/8/2020



There u go <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89888&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Hopefully, u name all your field names, table names to lowercase in future and remember how to dump out the values with the session variables and tips u picked up here.
Good luck!


Surely will remember and practice in the future