This topic is locked
[SOLVED]

 procedure to pre populate list from various tables?

7/20/2009 1:25:44 AM
PHPRunner General questions
R
roadyx author

Hi Jane, or Anyone,
I have a list that I would like to have prepopulated with data from several tables. Sort of an automatic in-line add capability, presenting the users a list and they can pick and choose by deleting the ones they don't want before saving.
I was able to do this on 4.x with smarty->assign.
Would like to request a sample code.
Example

Table A has 5 records

Table B has 5 records

Table C is target table

I would like to get all records from each table to prepopulate C Table (of course only records owned by user)
Kind Regards!
Roadyx

J
Jane 7/20/2009

Hi,
use Add page: Before process event to select values from another tables. Save selected values in the session variables and use these variables as default values on the "Edit as" settings dialog on the Visual Editor tab.

R
roadyx author 7/20/2009

Hi,

use Add page: Before process event to select values from another tables. Save selected values in the session variables and use these variables as default values on the "Edit as" settings dialog on the Visual Editor tab.


Can anyone come up with a sample please? THanks!

J
Jane 7/21/2009

Hree is just a sample:

global $dal;

$rs = $dal->TableName->Query("FieldName='".$_SESSION["UserID"]."'","");

$data = db_fetch_array($rs);

$_SESSION["Field1"] = $data["Field1"];

$_SESSION["Field2"] = $data["Field2"];

R
roadyx author 7/24/2009

Hree is just a sample:



Jane, I think it only works for add / edit page. I would like to to pre-populate the list page... If there are no records, it shows no records. Is this even possible?

J
Jane 7/24/2009

I'm not sure that I understand your question correctly.

What do you want to pre-populate on the list page?

R
roadyx author 7/24/2009

I'm not sure that I understand your question correctly.

What do you want to pre-populate on the list page?


OK let me try. This is like a shopping cart. Table A = 5 records , Table B = 5 records. Table C is the shopping cart no records there initially.

Here's the flow:

  1. When user goes to shopping cart (List page of Table C), I would like to read from table A and B and display results on the list page of Table C without inserting it**yet** to Table C
  2. User sees 10 items (from tbls A & <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42985&image=1&table=forumreplies' class='bbc_emoticon' alt='B)' />. User Selects items via checkbox of what they want to buy.
  3. User selects 3 items.
  4. User click PayNow button.
  5. Action of Paynow button is to insert 5 records into Table C. (The items the user selected)
  6. I record the session id. Table C also doubles as the User's receipt.
  7. So my main question is bullet number 1 above. Display read records from 2 tables without it being inserted yet to target table.
    Is this possible at all? If not, what's a good alternative?
    Kind Regards Jane!

J
Jane 7/27/2009

Hi,
you can create custom view on the Datasource tables tab and join two tables for this view on the Edit SQL query tab.