This topic is locked
[SOLVED]

 get the values of a given record listpage.

7/29/2011 6:07:36 AM
PHPRunner General questions
T
txqr author

I can not get the value of a given record listpage.
I created an alias in the table and convert the field into "custom" button to add creating a data record in another table.

In the "list page", each record won an add button, the idea is when I click this button, enter the data of this record in another table.
The button calls a php file that gives the 'insert'. It's working when I put the values​​, but when switch to variable, inserts null values ​​in fields (blank). Just $ _SESSION ["UserID"] works, other variables do not work.
What variables? -> I tried everything: $data ['name'], $values ​​= $ data ['name'], $_SESSION ['name'] = $data['name']
but when php file tries to get the name and others values of the current record, does not capture anything.
How do keep these values ​​in variables to be used by another file? - Remember that the $ _SESSION ["UserID"] works in this file.

C
cgphp 7/29/2011

In a custom field you can retrieve other field value with:



$value = $data['othe_field_name'];
T
txqr author 7/29/2011

I believe that is not enough, because I've tried doing this, and the external php file can not read the values ​​.... although he could read the value of $ _SESSION ["UserID"].
The problem is that in the "list page" several results are displayed, a button was created (the custom field, remember) for each one, the intention is to capture the values ​​of variables in the current record (the record that I to click on button) he calls the php file I created and performs an insert with the captured values​​.
This way that you told me, do not works

C
cgphp 7/29/2011

Please, post the code of the custom field and the code of the external php file.

T
txqr author 7/29/2011

Cristian,

follows as requested:
Custom field code

==================

$value = "<a href='addclients.php#' class='insert_link' id='".$data['primary_id_field']."'>"Add Client"</a>";
File addclients.php code

========================
Include dbcommon.php

global $conn;

$strSQLInsert = "insert into clients (ID, name, service) values ('".$_SESSION['UserID']."', '".$data['name']."', '".$data['service']."'")";

db_exec($strSQLInsert, $conn);
The "$_SESSION['UserID']" he insert, the others values don't

C
cgphp 7/29/2011

Custom field:



$name = urlencode($data['name']);

$service = urlencode($data['service']);

$value = "<a href='addclients.php?name=".$name."&service=".$service."' class='insert_link' id='".$data['primary_id_field']."'>Add Client</a>";


addclients.php

include "dbcommon.php";

global $conn;

$strSQLInsert = "insert into clients (ID, name, service) values (".$_SESSION['UserID'].", '".$_GET['name']."', '".$_GET['service']."')";

db_exec($strSQLInsert, $conn);
T
txqr author 7/29/2011

Cristian,

I can not test now, but later I will test.

I would like to thank you for the attention that you has give to us users and our doubts that certainly gives you a lot of work. Thank you!

T
txqr author 7/29/2011

I tried, but failed ...

the values ​​of other fields are blank
The data is there. It seems that the variable "$data" is not capturing the data ...
In Browser url show this:

http://localhost:8080/Add_clients.php?name=&service=

T
txqr author 7/29/2011

I did a test with: echo $data ['name'];

nothing ...

echo $ SESSION ['userid'];

exhibited: 1

echo $value;

exhibited: Julia
Why the variable "$value" put an "information" and the array $data did not save nothing?

is it because it is a "list page" of a BD view?
It makes no sense

C
cgphp 7/29/2011

Be sure that the name of the fields are name and service. "Name" is different from "name". Pay attention to capitalization.

T
txqr author 7/29/2011

Yes, it's true.

sorry
Thank you!!!