This topic is locked

Master Detail - populate list page field

1/27/2008 9:02:18 AM
PHPRunner General questions
L
Lisa2006 author

Hi Support,
When users go to your PHPRunner forum, they are presented with the views columns. Naturally, as users view posts, the views value increases for the respective post.
I need to create an identical solution. Here's my table settings:
Master Table: postings

Fields: company

name

posting_booking_ordernumber (Primary Key)

posting_viewed_todate
Details Table: removal_posting

Fields: company

name

posting_booking_ordernumber (Foriegn Key)

posting_viewed_todate
posting_viewed_todate: this field will store the incremental value.
I will need the users to see the incremental value on both the posting_list.php & removal_posting_list.php pages.
Not sure how to write the code.
Thanks in advance.
Lisa

J
Jane 1/28/2008

Lisa,
where do you want to increase posting_viewed_todate value: on the list or on the view page?

L
Lisa2006 author 1/28/2008

Hi Jane,
On the List page of tables postings & removal_posting
Thanks Jane
Lisa

J
Jane 1/28/2008

Lisa,
here is a sample code for the List page: Before process event for removal_posting table:

global $conn,$strTableName;

$strUpdate = "update removal_posting set posting_viewed_todate= posting_viewed_todate+1 where posting_booking_ordernumber=".$_SESSION[$strTableName."_masterkey1"];

db_exec($strUpdate);


Not sure how to update more then one records in the postings table on the list page.

Please clarify.

L
Lisa2006 author 1/28/2008

Thanks for the code.
Getting the follow error:
Error Type: 2

Error Description: Missing argument 2 for db_exec()
Please Help
Lisa

L
Lisa2006 author 1/28/2008

Hi Jane,
I've amended the code snippet on the List page: Before process event on the removal_posting table as below:
global $conn,$strTableName;

$strUpdate = "update removal_posting set posting_viewed_todate= posting_viewed_todate+1 where posting_booking_ordernumber=".$_SESSION[$strTableName."_masterkey1"];

db_exec($strUpdate,$conn);
It now eliminates the previously reported error. However, i do not see the posting_viewed_todate field updated on either the removal_posting table or postings table.
Please help
Lisa

J
Jane 1/29/2008

Lisa,
please make sure this query is executed.

To debug your code print SQL query on the page and execute it in the database directly:

global $conn,$strTableName;

$strUpdate = "update removal_posting set posting_viewed_todate= posting_viewed_todate+1 where posting_booking_ordernumber=".$_SESSION[$strTableName."_masterkey1"];

echo $strUpdate;

db_exec($strUpdate,$conn);

L
Lisa2006 author 1/29/2008

Hi Jane,
I've placed new code snippet in the List Page: Before Process on the removal_posting table.
When executed i get the following errror:
Echo's the following: update removal_posting set posting_viewed_todate= posting_viewed_todate+1 where posting_booking_ordernumber=R118
Error Type: 256

Error Description: Unknown column 'R118' in 'where clause'
Sorry i do not understand what is meant by "To debug your code print SQL query on the page and execute it in the database directly:

"
Please Help
Lisa

J
Jane 1/29/2008

Lisa,
you need to add single quotes around posting_booking_ordernumber field in your query:

global $conn,$strTableName;

$strUpdate = "update removal_posting set posting_viewed_todate= posting_viewed_todate+1 where posting_booking_ordernumber='".$_SESSION[$strTableName."_masterkey1"]."'";

echo $strUpdate;

db_exec($strUpdate,$conn);

L
Lisa2006 author 1/29/2008

Hi Jane,
Work!!!
However, how can i pass the incremented value held in the removal_posting table, posting_viewed_todate field back to the posting_viewed_todate field in the postings table.
Thanks in advance
Lisa

J
Jane 1/29/2008

Lisa,
you can update postings table in the same event.

L
Lisa2006 author 1/29/2008

Hi Jane,
Sorry, i don't know what code to use.

Would i place this code snippet in the List page: Before process event on the removal_posting table ?
Please Help
Lisa