473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Working with a table from inside a databse row

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?

Apr 20 '06 #1
5 1052
You can simply add a block of PHP code to the page content in the DB
and have it parsed by eval().

PS: Don't kill me for suggesting eval(). It's the most simple and
flexible solution here.

Apr 20 '06 #2
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.

Apr 20 '06 #3
> 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

Apr 20 '06 #4
Thanks!

I didn't realize I had to jump through this little hoop:

eval ("?>" . $row['centercontent'] . "<?php ");

Why do you have to use those tags in this case? (?>, <?)

Eval() should be called Evil().

Apr 21 '06 #5
ma*******@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

Apr 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jedbob | last post by:
I used Adobe Imageready to build a simple rollover navigation bar, where the text will change color on a mouse over. The working example can be found at:...
0
by: Harry Yau | last post by:
Hi all, I am writing a pl/psql function with a temp table right now. It creates the temp table inside. Whenever I call this function in a session for the first time, it creates a shema, namely...
0
by: Harry Yau | last post by:
Hi all, I am writing a pl/psql function with a temp table right now. It creates the temp table inside. Whenever I call this function in a session for the first time, it creates a shema, namely...
4
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be...
4
by: Martínez | last post by:
Hi, Here's a scaled down version of what I'm working with. It execututes correctly in IE, but FireFox fails to run it. The JavaScript Console reports the error "Error:...
2
by: nittin14 | last post by:
hello guys, pls solve my problem my problem is that i m retreive data from table but in some column the value is store NULL. i want that insist of NULL it wl display some text in datalist while...
3
by: MarkTingson | last post by:
hi scripters! is it possible in vb to transfer the table in a databse into an external memory disk? i just want to save ONLY THE TABLE but NOT THE ENTIRE DATABSE in a flashdisk! pls tell me how......
2
by: lynx129 | last post by:
Hi there , I have php script that works fine under my server but I dont know how to put the html code inside my site. feedback.html <html dir="rtl"> <head> <title> ????? ??? </title>...
1
by: filch | last post by:
Hi, I am new to this forum ... so hello to all! I am trying to get a script working which will show or hide a table based on a user checking or unchecking a parent checkbox. This is the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.