This topic is locked

obtaining field and cell value

1/9/2009 12:43:49 AM
PHPRunner General questions
P
phprookie author

I am admittedly new to PHPRunner and PHP <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=10591&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' /> and would really appreciate some guidance.
DB table
[codebox]CREATE TABLE [dbo].[customer] (

[cust_id] int IDENTITY(1,1) NOT NULL,

[cust_name] varchar(50) NULL,

[ext_build] varchar(50) NULL,

[start_path] varchar(255) NULL,

[stop_path] varchar(255) NULL,

[status] varchar(255) NULL,

[env_host] varchar(255) NULL,

CONSTRAINT [PK_customer] PRIMARY KEY([cust_id])

)[/codebox]
What I want is to create 2 buttons to send the field env_host value via a URL as a variable to an external PHP page.

It took some digging around and I was able to create the buttons using the code snippet
Here's the code snippet:
[codebox]
function customer_buttons(&$params)

{
// I tried this block below but kept running into syntax errors.

//global $conn,$strTableName;

//$str = "select env_host from customer where cust_id = ".$_SESSION[$strTableName."_masterkey1"];

//$rs = db_query($str,$conn);

//$data = db_fetch_array($rs);

//echo "The ENV Host: ".$data["env_host"];

//$env_host_value = $data["env_host"];
$env_host_value = "emy-dnguy2"; //this was an example just to make sure the call worked
$start = "<input type=button id=start name=start value=\"start\" onclick=\"window.open('start.php?" . $env_host_value . "')\">";

$stop = "<input type=button id=stop name=stop value=\"stop\" onclick=\"window.open('stop.php?" . $env_host_value . '")\">";

$value = $start . $stop;
echo "
" . $value;
} // function customer_buttons
[/codebox]
What I am having a problem with is trying to assign $env_host_value variable the env_host value from these env_host cell and dynamically build the buttons. Any suggestions or advices you can provide would be greatly appreciated.

J
Jane 1/9/2009

Hi,
use custom format for env_host field on the "View as" settings dialog on the Visual Editortab for this purpose.

Actual value is in the $value variable:

$start = "<input type=button id=start name=start value=\"start\" onclick=\"window.open('start.php?" . $value . "')\">";

$stop = "<input type=button id=stop name=stop value=\"stop\" onclick=\"window.open('stop.php?" . $value . '")\">";

$value = $start . $stop;

P
phprookie author 1/9/2009

Hi,

use custom format for env_host field on the "View as" settings dialog on the Visual Editortab for this purpose.

Actual value is in the $value variable:


Thanks a million Jane. That worked perfectly.

P
phprookie author 1/9/2009

Hi Jane,
One last question and I'm golden <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=36676&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
Your suggestion made it so it worked perfectly and I am able to capture and post the URL with the env_host field value
http://localhost/start.php?env_host=myenvhost
Now let suppose I want to add a second value from another field (start_path) onto this URL request something like this
http://localhost/start.php?env_host=myenvh...ath=mystartpath
Can you suggest how this can be done presently with PHPRunner?

Thanks.

P
phprookie author 1/9/2009

Nevermind... I was able to get the results I wanted after some hair pulling <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=36682&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
What I essentially did was merged the env_host, stop_path, and start_path fields all onto one single cell in the visual editor then added custom view for stop_path and start_path


Here are the code snippets, maybe it will help somebody along the way
[codebox]

//for stop button

$host = ProcessLargeText(GetData($data,"env_host", ""),"field=env%5Fhost","",MODE_LIST);

$path = ProcessLargeText(GetData($data,"stop_path", ""),"field=stop%5Fpath","",MODE_LIST);
$stop = "<input type=button id=stop name=stop value=\"stop\" onclick=\"window.open('stop.php?env_host=" . $host . "&stop_path=" . urlencode($path) . "', 'newwindow', config='height=150,width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no')\">";

$value = $stop;

[/codebox]
[codebox]

//for start button

$host = ProcessLargeText(GetData($data,"env_host", ""),"field=env%5Fhost","",MODE_LIST);

$path = ProcessLargeText(GetData($data,"start_path", ""),"field=start%5Fpath","",MODE_LIST);
$start = "<input type=button id=start name=start value=\"start\" onclick=\"window.open('start.php?env_host=" . $host . "&stop_path=" . urlencode($path) . "', 'newwindow', config='height=150,width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no')\">";

$value = $start;

[/codebox]
If anyone sees a better way to do this please let me know. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=36682&image=3&table=forumreplies' class='bbc_emoticon' alt=':D' />