This topic is locked
[SOLVED]

 view page include file help

2/9/2011 7:01:30 PM
PHPRunner General questions
J
jetacera author

I'm using phprunner 4.2 (I know... it's older, but it suits my purposes).
I have a project using just a list page and a view page. The view page has an include file that I've created myself to call up a list of specific data from another database table. I want the list to only include data records assigned to this view page using the primary key of the view page, but I can't seem to figure out how to make that field change within the sql query of the include file.
Here is my SQL query to explain further:
SELECT id, description, html AS htmlcode, js AS jscode, page_display, column_display, displayrank FROM content WHERE page_display =1 and column_display =1 ORDER BY displayrank, id ASC
The include file in the include folder. This query works, but only on the view page with the primary key of 1.
I want the page_display =1 to be page_display =(primary key of the current view page) so that each view page will bring up a different list. Any suggestions would be greatly appreciated.

J
jetacera author 2/9/2011

OK, I played around a bit longer and found a solution:
I added the following before my sql query in the include file:
global $strTableName, $conn;
$keys=array();

$keys["id"]=postvalue("editid1");
$strSQLExists = "select * from sitepages where id='".$keys["id"]."'";

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

$data=db_fetch_array($rsExists);

if($data)

{

$_SESSION["pageid"] = $data["id"];
}
$query="SELECT id, description, html AS htmlcode, js AS jscode, page_display, column_display, displayrank FROM content WHERE page_display ='".$_SESSION["pageid"]."' and column_display =1 ORDER BY displayrank, id ASC";