This topic is locked

Combineg text and ID in a default value

3/16/2009 4:13:18 PM
PHPRunner General questions
M
mmponline author

I need to add a default value in a field, consisting of
A fixed path:

"http://localhost/rsvp/userfunctions_view.php?editid1=";
and the session value of the Table's ID

$_SESSION["FunctionID"]
How do I do this to get eg.
http://localhost/rsvp/userfunctions_view.php?editid1=9
as the result.
Please help.

Sergey Kornilov admin 3/16/2009
"http://localhost/rsvp/userfunctions_view.php?editid1=" . $_SESSION["FunctionID"]
M
mmponline author 3/17/2009

Thanks, this does the trick just fine!

M
mmponline author 3/17/2009

Not really working - One problem
The number added as the $_SESSION["FunctionID"] is one less than the new number of the record being created. Obviously because the record was not saved yet.
Thus Record
FunctionID 18 has a link of http://localhost/rsvp/userfunctions_view.php?editid1=17

FunctionID 19 has a link of http://localhost/rsvp/userfunctions_view.php?editid1=18
How can I fix this?
I need the user to be able to copy this link, and set it in a hyperlink for people to respond to. The link will thus be different for each record.

J
Jane 3/17/2009

Stephan,
what code do you use to select $_SESSION["FunctionID"] value?

M
mmponline author 3/17/2009

In the list page: Before SQL Query:

global $dal;

$rs = $dal->functions->Query($strWhereClause,"");

$data = db_fetch_array($rs);

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


and then the code you provided on a Link field as a readonly with the default value:

"http://localhost/rsvp/userfunctions_view.php?editid1=" . $_SESSION["FunctionID"]
Sergey Kornilov admin 3/17/2009

Stephan,
the seems to be a flaw in the logic.

On the List page you trying to calculate a value of record that wasn't added yet. Not sure how is that supposed to work.
Probably you need to explain what exactly you trying to achieve.

M
mmponline author 3/17/2009

Let me try:
I have a table (names function) with a related table where peaople can RSVP for the function.

I've created a custom view (called AddRSVP) where people will complete the Add table as a form similar to the cars and properties templates. All works well.
The idea is that on the function table I want to add a field where people can copy the link to the AddRSVP table. This link can then be sent (or added as a link on a picture) to allow prospective guests to reply on this form. The form is accessed via the userfunctions_view.php table as this is the only way I can get the session values to ber written to the form.
The link should thus contain the fixed link ( "http://localhost/rsvp/userfunctions_view.php?editid1= plus the session ID

" . $_SESSION["FunctionID"]

to ensure that the link clicked will open the specific functions form.
Thus I need a way to display the link with the ID of the function. The user will add a function, copy the link and paste it in his e-mail and send it off.

I've even tried to use concat string by trying to add the Link and ProjectID together. Can't seem to crack it.
Hope this helps to explain my logic.

Sergey Kornilov admin 3/17/2009

Sorry, it's not easy to follow.
Anyway, I think you can get better results using 'View as' type 'Custom'. Using a real table field for this purpose seems to be an overkill.