This topic is locked

Before add event based on Sessionid

2/14/2007 9:17:18 PM
PHPRunner General questions
G
gdude66 author

Hi,

I am try to fill sections of the add page as it loads.

In the add page I have student code which is a read only owner id field pulled from session data.
I would then like it to fill a read only box called home group which is pulled from another table called student and the field is home group.
Is this possible? I would like the field visible on the add page or does it need to be handled by events as it is added?
Could I get some help with the syntax for this please?

Alexey admin 2/15/2007

Graeme,
all you need here is Add OnLoad event.

Select data from the database and assign it to home group field using this code:

global $smarty;

$smarty->assign("value_home_group", $value);


If this doesn't work proceed to Visual Editor and inspect Home group control on Add page in HTML mode to find proper value_... name

G
gdude66 author 2/15/2007

Graeme,

all you need here is Add OnLoad event.

Select data from the database and assign it to home group field using this code:
If this doesn't work proceed to Visual Editor and inspect Home group control on Add page in HTML mode to find proper value_... name



The home group field is in a different table table is called student and field is called homegroup than the table this event will write to - so where and what do I put this into?

My apologies - it has been 4 months since I readdressed this project and it is surprising how rusty your skills get.

G
gdude66 author 2/16/2007



The home group field is in a different table table is called student and field is called homegroup than the table this event will write to - so where and what do I put this into?

My apologies - it has been 4 months since I readdressed this project and it is surprising how rusty your skills get.



SO how would you do this as an event so it is unseen by the user?

Alexey admin 2/16/2007

Graeme,
select a value from your database table and then use the code I provided to put this value to the field.
You need to know some PHP to do this.

G
gdude66 author 2/16/2007

Graeme,

select a value from your database table and then use the code I provided to put this value to the field.
You need to know some PHP to do this.



A hint please. The smarty stuff is a bit new.
I want to select home group from the table students and insert it into the red only box called homefroup on the edit page which writes to a table called goals.

Alexey admin 2/16/2007

Graeme,
I gave you the code that deals with smarty.

We don't have a ready to go solution for your task.
Here are some useful links about selecting data from a database table.
http://www.webcheatsheet.com/php/connect_mysql_database.php

http://www.w3schools.com/php/php_mysql_select.asp

http://www.php.net/mysql

G
gdude66 author 2/16/2007

In the end I used before add events - it works well without mucking around with smarty code which I couln't get to work and I am out of time.

global $conn;

$strSQLExists = "select * from student where code='".$_SESSION["UserID"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

$values["class"] = $data["form group"];



For anyone else that gets stuck here.