Echo query until search variable is found using substr()
Posted: Tue Mar 09, 2004 9:05 am
Hello, I'm new here!
I'm working on my website redesign, and except for a few things, it's gone smoothly. Now I'm actually inserting the data into the mySQL database, and I found that I need somekind of UNTIL function when grabbing data from the database.
I have two tables in my database, 'directory', and 'pages'. My site is organised into directorys, then pages inside directorys.
So in the 'directory' "Lego Creations" I have "Lego Plane", "Lego Car" linked to "Lego Creations" in my 'pages' table.
What I want to do is have the main 'directory' pages have a little bit of information about my "Latest Creation" or update, by
Now, I inside the 'pages' entrys I have them divided into 'subsections' using monkey_code. For instance, in the pages that are in my "Lego Movies" directory, I have the directors writeup, then I put [downloadinfo] and my php script replaces that with
.
What I want the main page of each of my directorys to do is echo the content of the latest creation in that category, UNTIL it sees [downloadinfo] or some such other variable.
So, to recap:
my code should grab the latest entry in the 'pages' table, but only from the entries that are tied to the correct 'directory' row. My code should then echo the content in respective 'pages' row, UNTIL it sees [downloadinfo], when it should just stop printing the data from the db.
Also, I tried substr(), but since it only works with numbers, or so I've been told, it didn't work out well. The length of my entries changes each time!
Is this even possible? I've never heard of such a thing, but with php anything is possible, so I'm sure it can be done!
If I did not make something clear enough, I apologize, I will be glad to clear up any questions you may have.
- The Monkey
I'm working on my website redesign, and except for a few things, it's gone smoothly. Now I'm actually inserting the data into the mySQL database, and I found that I need somekind of UNTIL function when grabbing data from the database.
I have two tables in my database, 'directory', and 'pages'. My site is organised into directorys, then pages inside directorys.
So in the 'directory' "Lego Creations" I have "Lego Plane", "Lego Car" linked to "Lego Creations" in my 'pages' table.
What I want to do is have the main 'directory' pages have a little bit of information about my "Latest Creation" or update, by
Code: Select all
SELECT * FROM pages WHERE name = '$directoryname' LIMIT 1Code: Select all
<hr><b>Download Information:</b>What I want the main page of each of my directorys to do is echo the content of the latest creation in that category, UNTIL it sees [downloadinfo] or some such other variable.
So, to recap:
my code should grab the latest entry in the 'pages' table, but only from the entries that are tied to the correct 'directory' row. My code should then echo the content in respective 'pages' row, UNTIL it sees [downloadinfo], when it should just stop printing the data from the db.
Also, I tried substr(), but since it only works with numbers, or so I've been told, it didn't work out well. The length of my entries changes each time!
Is this even possible? I've never heard of such a thing, but with php anything is possible, so I'm sure it can be done!
If I did not make something clear enough, I apologize, I will be glad to clear up any questions you may have.
- The Monkey