This topic is locked

S earch button on view page to search another table

6/17/2008 11:33:20 PM
PHPRunner General questions
B
bochaka author

Hi

Is it possible for me to put a search button on a view page which when pressed would display a list of records from another table associated with the current record being displayed. For example the displayed record (in a view page) is of a dog named REX, and there is a button labeled "Click to find litters by Rex", .Rex would be a dog name in a field called SiresNAMES in a table called Litters.

J
Jane 6/18/2008

Hi,
you can do it using custom event (Insert PHP code snippet option on the Visual Editor tab).

Here is a sample:

$str = "<input type=button value=search onclick=\"window.open('URL');\">"



Replace URL with your actual URL with search parameters.

B
bochaka author 6/18/2008

So how would the code look if i my url is http://www.123.com and the current view.php page is for a dog (in a table called studdogs, field name dogsname )named rex and I want to search a table called litters which has a field called sires, for a dog named rex whose view page is currently being displayed. Sorry about this but my code skills are not great

.

J
Jane 6/19/2008

Hi,
just open litters table, run search, then copy resulting URL to your code.

To pull values from view page use this code:

global $conn;

if (@$_REQUEST["editid1"])

{

$rs = db_query("select dogsname from studdogs where RecordID=".$_REQUEST["editid1"],$conn);

$data = db_fetch_array($rs);

}



All field values from the view page are stored in the $data array.

B
bochaka author 6/19/2008

Hi Jane

I dont quite understand how to run search, can you please tell me more about this bit.

J
Jane 6/20/2008

Hi,
to run search open list page in browser, enter value to the search box and click on the Search button.

B
bochaka author 6/23/2008

Hi Jane

I tried this ,but when the page loads i get this message.

Parse error: parse error, unexpected T_GLOBAL in C:\UserAccounts\www\bochaka_bochaka_com\may28ver1_20080623041148\include\_studdogs_events.php on line 42

I put all the code into the event page for this page using the add code snippet. The full code is:
$str = "<input type=button value=search onclick=\"window.open('www.germanshepherdpups.ie/gsddb1/_litters_list.php?a=search&value=1&SearchFor=&SearchOption=Equals&SearchField=sire';);\">"

global $conn;

if (@$_REQUEST["editid1"])

{

$rs = db_query("select sired by from _studdogs where RecordID=".$_REQUEST["editid1"],$conn);

$data = db_fetch_array($rs);

}
Regards

J
Jane 6/24/2008

Hi,
you've missed semicolon in your code:

$str = "<input type=button value=search onclick=\"window.open('www.germanshepherdpups.ie/gsddb1/_litters_list.php?a=search&value=1&SearchFor=&SearchOption=Equals&SearchField=sire';);\">";

global $conn;

if (@$_REQUEST["editid1"])

{

$rs = db_query("select sired by from _studdogs where RecordID=".$_REQUEST["editid1"],$conn);

$data = db_fetch_array($rs);

}

B
bochaka author 6/24/2008

Hi Jane

I made the change .The page now displays , but has PHP ERROR HAPPENED where the button should be, have I missed something else. The project is in the demo account should you need to see it.

Regards

J
Jane 6/24/2008

Send direct link to your pages to support@xlinesoft.com.