This is a discussion on Working with a table from inside a databse row within the PHP Language forums, part of the PHP Programming Forums category; I have a simple site layout. Everything is being pulled from a database in such fashion that Page 1 of ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have a simple site layout. Everything is being pulled from a
database in such fashion that Page 1 of the site is referenced by 'pagename.php/?id=1', Page 2 is referenced by 'pagename.php/?id=2', and so forth. In other words, I have only one page 'pagename.php' with a couple of conditional statements and a navigation bar as a form using method "get". I need the middle content part on page 'pagename.php/?id=3' to pull some information from a completely separate table. Is there a way to accomplish that without resorting to if ($_GET[id] = 3) { // do a completely separate page layout with data pulled by the needed page } I don't want to hardcode the condition because a user may delete row where id=3. Basically, is there a way to run a database query from inside a database row while in phpMyAdmin? |
|
|||
|
Thank you for replying. Could you be more specific, please?
Again, it goes something like this: Table structure tbl_siteLayout (ID, pageName, pageLeftContent, pageMiddleContent, pageRightContent) The navigation bar is pulling ID, creates 'pagename.php/?id=' links, and the 'pagename.php' uses $_GET to run a query where id = $_GET[id] to display all content. One of those pages referenced by id=3 needs to contain a list of products pulled out of tbl_Products (productID, productName, productDesc, productPrice). Are you suggesting INSERTing entire tbl_Products code directly into the 'tbl_siteLayout.pageMiddleContent' field? Thanks. |
|
|||
|
> Are you suggesting INSERTing entire tbl_Products code directly into the
> 'tbl_siteLayout.pageMiddleContent' field? No, just store sth. like ----- <ul> <?php // connect to mysql, query and parse result ?> </ul> ----- in the database and instead of printing the contents pass them to eval(): ----- <?php // fetch $content from mysql eval($content); ?> ----- Since you don't have access to variables as you would have with include(), you have to connect to mySQL in the eval'ed code separately. Cheers, milahu |
|
|||
|
maxvalery@gmail.com wrote:
> Why do you have to use those tags in this case? (?>, <?) eval() parses in `PHP-mode', so you have to close and re-open the PHP tags when passing HTML contents to it. Cheers |