Re: [PHP-DB] Generate Menu based on database structure
Hi, Rather than writing a recursive function I'd suggest that you create a menu class and store each record as an object of the class. The menu class will have variables of id, parent, title, children, and tree. The children will be initialised to 0 and tree will be initialised to 1. You will need to write a function to find any menu object given the menu's ID, should be easy if you store each object in an array (keyed on the ID) 1) Read in a record and create a menu object 2) Get the parent object, using the parent variable and the find method 3) Increment the children variable in the parent menu object by one 4) Set the tree variable in the new menu object to the tree object in the parent object plus the value in the children object. Now add method to display the menu items and your problem should be solved. Gavin Amm wrote: Hi guys, I need to generate a menu based on the content structure of my database. The data is structured using an 'id' 'parent' relationship, for eg: id parent title 1 0 Home Page 6 1 My Page 2 9 6 My Page 3 15 9 My Page 4 21 6 My Page 5 22 9 My Page 6 23 22 My Page 7 24 22 My Page 8 25 1 My Page 9 28 25 My Page 10 I need to create a recursive loop that will create the menu. The text in the brackets is what I'm trying to achieve, the rest is just for aesthetics ease of reading. (The children of the row id=1 are the top of the menu tree, ie they will be the menu categories at the top of the web page to display the menu when the mouse hovers over it.) (Each menu item, being a menu, will have a href to it's id number.) My Page 2 (Menu_1) My Page 3 (Menu_1_1) My Page 4 (Menu_1_1_1) My Page 6 (Menu_1_1_2) My Page 7 (Menu_1_1_2_1) My Page 8 (Menu_1_1_2_2) My Page 5 (Menu_1_2) My Page 9 (Menu_2) My Page 10 (Menu_2_1) I just can't for the life of me get the numbering to work correctly in the recursion. I seem to get things like (1_1_2_1_2_3_1_2_3_4) which I can see the pattern in, but it's obviously not what I'm after.. Appreciate your help. Thanks, Gav. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Convert a SQL compliant date to Epoc Unix seconds
Hello, Sorry if the question has already been posted, I checked the archives and didn't find anything related. I'm looking for a simple way to convert a SQL compliant date (eg 2004-09-06) into a Unix Epoc seconds (similar to the one returned by function time()). Thanks. Stephane -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Convert a SQL compliant date to Epoc Unix seconds
Stphane Pinel wrote: I'm looking for a simple way to convert a SQL compliant date (eg 2004-09-06) into a Unix Epoc seconds (similar to the one returned by function time()). strtotime() or the database may have something you can use in your query (like UNIX_TIMESTAMP() in MySQL). -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] HTML stored in a text field
I have a database which has a BLOB field storing text... It should probably be in a text field, but I don't think that's the problem... The field has HTML control codes, such as b, /b, and p. When I echo them from the database, a la: echo td . $row['textfield'] . /td I get the contents of the field with the tags showing up, isntead of applying to the HTML. How can I get these tags to aplpy to the text in the field? Thanks! Gabe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] HTML stored in a text field
Gabe Covert wrote: I have a database which has a BLOB field storing text... It should probably be in a text field, but I don't think that's the problem... The field has HTML control codes, such as b, /b, and p. When I echo them from the database, a la: echo td . $row['textfield'] . /td I get the contents of the field with the tags showing up, isntead of applying to the HTML. How can I get these tags to aplpy to the text in the field? Thanks! Gabe To my knowledge you can't - a textarea only displays text, not formatted text. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Session confusion
Back to my multi page form again ;) I am going to try it with Session variables . So, one thing is confusing me. The page requires the user to be logged in and is being tracked via authentication. Do I still need to do a session_start();, at the beginning of the form process ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] HTML stored in a text field
Gabe Covert wrote: I have a database which has a BLOB field storing text... It should probably be in a text field, but I don't think that's the problem... The field has HTML control codes, such as b, /b, and p. When I echo them from the database, a la: echo td . $row['textfield'] . /td I get the contents of the field with the tags showing up, isntead of applying to the HTML. How can I get these tags to aplpy to the text in the field? Not really following your explanation, but if you have bword/b as your text and you want the actual bolded word to show up in the table cell, then use what you have above. If you want the literal bword/b to show up, then use this: echo 'td' . htmlentities($row['textfield']) . '/td'; -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Recursively determine parent records?
Here's a piece of some code I wrote that does what you want. You'll need to change the WhoIsMyParent() function to match your database abstraction and schema. $array = BreadCrumbs($id); print_r($array); exit; function BreadCrumbs($parent) { // construct an array of indexes that represents the path back to the // root from my current location in the tree. $PathStack = array(); array_push($PathStack,$parent); $MyParent = WhoIsMyParent($parent); while ($MyParent != 0) {// 0 = top of the tree $PathStack[] = $MyParent; $MyParent = WhoIsMyParent($MyParent); } $PathStack = array_reverse($PathStack); return $PathStack; } function WhoIsMyParent($id) { $row=FetchRow(QueryDb(select parent from sometable where id=.$id)); if ($row == NULL) return 0; return $row['parent']; } -Original Message- From: Murray @ PlanetThoughtful [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 05, 2004 11:58 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Recursively determine parent records? Hi All, I have recordset that contains a hierarchical representation of records where a record's [parentid] field contains the recid of the record 'above' the current record. A representation might look like this: Recid, parentid, title 1, 0, Top level record 2, 0, Another top level record 3, 1, A record under the top level record 4, 3, Another level 5, 2, A record under the second top level record If I have currently retrieved the record with recid of 4, I want to work out the 'chain' of records that lead back to the top level record it has been created under. In this instance, that chain would look like: 4, 3, Another level 3, 1, A record under the top level record 1, 0, Top level record I'm wondering if anyone can help me work out how to achieve this? Many thanks in advance! Much warmth, Murray http://www.planetthoughtful.org/ http://www.planetthoughtful.org Building a thoughtful planet, One quirky comment at a time. smime.p7s Description: S/MIME cryptographic signature
[PHP-DB] Re: Session confusion
Stuart, I am fairly new to PHP, but it is my understanding that you have to run the session_start() command on every page that you want to be part of the session and to access the session variables. Here is a link of a tutorial about using sessions: http://www.phpfreaks.com/tutorials/41/3.php Look for the word MUST in red and read that paragraph. It should tell you what you need to know. Hope that helps, Aaron Stuart Felenstein [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Back to my multi page form again ;) I am going to try it with Session variables . So, one thing is confusing me. The page requires the user to be logged in and is being tracked via authentication. Do I still need to do a session_start();, at the beginning of the form process ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Backup
Andrew, I like the idea of using the crontab even though I have never used it before. I guess the first thing I need to do is make my script. Thanks for the link to mysqldump, I think it will be usefull. Do you happen to know how I might be able to push a file to another server using FTP? Just playing around the past few days I have created a script that will get the contents of the table and bring up a download window so I can download it into an Excel file. It doesnt use mysqldump, but it works. But I need it to send the file to my FTP server automaticly. Any suggestions?? Thanks, Aaron Andrew Kreps [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tue, 5 Oct 2004 16:33:08 -0400, Aaron Todd [EMAIL PROTECTED] wrote: What is everyone doing to backup a MySQL database. Just in case...I'd like to backup mine, but I was wondering if there was a way to do it without going to a page and clicking a button. Is there a way to run a php script on a time schedule and then push a backup file to an FTP server or something. Anyone out there doing anything like this? Personally, I go straight to the source. http://dev.mysql.com/doc/mysql/en/mysqldump.html You can write a PHP script that runs the dump, compresses the file and FTP's the file anywhere you like. As Martin mentioned, You can run this PHP script from your crontab or Task Scheduler by invoking the interpreter from the command line, i.e. '/usr/local/bin/php /home/mydir/scripts/backupDB.php'. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Session confusion
Okay, I will read the tutorial. I also want to clarify a bit more. I guess it's my intention to not have the form session relying on the auth session, since I want to expire the form session , either at the end of the transaction or if user cancel out on the form. So either the cookie or session dies at that point. Whichever one they are using. Stuart --- Aaron Todd [EMAIL PROTECTED] wrote: Stuart, I am fairly new to PHP, but it is my understanding that you have to run the session_start() command on every page that you want to be part of the session and to access the session variables. Here is a link of a tutorial about using sessions: http://www.phpfreaks.com/tutorials/41/3.php Look for the word MUST in red and read that paragraph. It should tell you what you need to know. Hope that helps, Aaron Stuart Felenstein [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Back to my multi page form again ;) I am going to try it with Session variables . So, one thing is confusing me. The page requires the user to be logged in and is being tracked via authentication. Do I still need to do a session_start();, at the beginning of the form process ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] code example to store PHP session data in mySQL ?
Hi @ all, where can I find a working example that shows me how to implement PHPSESSION with MySQL as stor? tia -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] code example to store PHP session data in mySQL ?
where can I find a working example that shows me how to implement PHPSESSION with MySQL as stor? i know adodb has session functions, download it a nd take a look maybe here http://www.devarticles.com/c/a/MySQL/Developing-Custom-PHP-Sessions/ also try google. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Backup
On Wed, 6 Oct 2004 15:31:34 -0400, Aaron Todd [EMAIL PROTECTED] wrote: Do you happen to know how I might be able to push a file to another server using FTP? I might http://us4.php.net/ftp has a list of all the FTP related PHP functions with some ready-to-use examples. Enjoy! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php