The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
form standard in 4.2 - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: form standard in 4.2 (/showthread.php?tid=594)



form standard in 4.2 - marceloatmartins - 06-13-2017

Hi folks, what do I need to make a form like master / detail (2 tables) in Us 4.2 ? Which required packages I need to load in a new form ?
Thanks everybody


form standard in 4.2 - mudmin - 06-14-2017

Hmm. I'm not sure exactly what you're talking about. You don't need anything special to do this.

You want to tie the two tables together with some sort of id, so...
Let's just say you have table 1 called master, your columns would look like

id (int 11, auto incremented)
//then whatever other columns you want

Then I'm assuming that you want table two to possibly have many lines that all connect to the master table. This one is called details

That one would have
id (int 11, auto incremented)
master_id (int 11)
//then whatever other columns you want

So, you would do your inserts in two steps...

Code:
$fields = array(
Code:
your_data=>"the_actual_data"
Code:
);

Code:
$db->insert('master',$fields);
THEN you need to get that id back
Code:
$master_id = $db->lastId();

So now you do your second query
Code:
$fields2 = array(
Code:
master_id = $master_id,
Code:
your_data=>"the_actual_data"
Code:
);

Code:
$db->insert('details',$fields2);

This video is about 30 minutes, but I think it will save you a lot of time in the long run...
https://userspice.com/documentation-db-class/


form standard in 4.2 - marceloatmartins - 06-19-2017

Thank you Dan, your suggestion help me a lot. Execelent tutorial.
Hugs


form standard in 4.2 - mudmin - 06-20-2017

Awesome! Glad it helped!