11 Replies Latest reply on Oct 16, 2008 9:21 AM by Günter Schenk

    How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by

    mrcharis2003@yahoo.c Level 1
      Hi there

      I am trying hard to set up a dynamic flash slideshow that uses an xml feed

      I have the whole slideshow working great but I cant filter the xml feed page by a url variable passed from the detail page...

      I will explain....

      The slideshow I am using uses a php xml page that uses a DW recordset to pass the correct database picture location to the slideshow..... all works great

      But..... i can't figure out how to how to filter the recordset on that xml page using a url variable...

      An example I am creating is.... I have an art gallery website that I am working on ... with loots of effort it is working well....

      I can add new artists and paintings to to the site easy and when you click on an artist it takes you to their detail page artistgallery.php.... that displays only their paintings..... took ages to figure out how ...passing the artist_id from the master to detail page then filtering the recordset....

      Now I have a slideshow that is fed using a php page that has xml code that I want to insert into that detail page ... the slideshow also uses a DW recordset on a seperate php page that has xml code... a "get_pic.php page

      Now the get_pic.php page has a recordset that I can test using no filter and it works great sends all the images to the slideshow no problem but I need to filter the recordset by url parameter id_artist (the same as for the recordset artistgallery.php when I try that I get nothing I understand why.... the get_pic.php needs to get the passed url from the detail page (or even the master page) so it can filter the recordset by that value....... so I try to add a link from the artistgallery.php page +to the get_pic.php labled 'Get pics for slideshow' passing the correct varriable and it works it does pass the variable and when I test the get_pics.php page it now retrieves the correct data filtered by the passed url but when I go back to the artistgallery.php page the slideshow is still empty ....

      Is there a way to pass the artist_id variable automatiaclly to the get_pic.php page so that the recordset on the get_pic.php page filters the records correctly using the passed url..... without using a link.. that you have to click to pass the variable?

      I think that when you click on an artists name on the index page the artist_id url variable has to be passed to the get_pic.php page at the same time as it is passed to the artistgallery page.... so that the slideshow on the artistgallery page can be fed with the correct data...????

      Sounds a bit much but is actually pretty simple I just cant figure out how to do it....

      Any help or suggestions would be great

      Have a nice day
        • 1. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
          Günter Schenk Level 4
          Hi Charis,

          --------
          Is there a way to pass the artist_id variable automatiaclly to the get_pic.php page so that the recordset on the get_pic.php page filters the records correctly using the passed url..... without using a link.. that you have to click to pass the variable?
          --------

          not sure I completely understand your issue, but maybe you´d - at some point, assumingly the artistgallery.php detail page - just have to establish a PHP session that´s storing the artist_id URL variable and use the newly created session variable as filter condition in get_pic.php

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
            mrcharis2003@yahoo.c Level 1
            Hi there <br /> <br />Thanks so much for your answer sounds like it should work <br /> <br />i have not had much experience with using sessions only with using the default KTuser_login session variable.... so I am a bit lost <br /> <br />I have been searching the adobe forums and googling all morning and I am still lost I have found some info on how to start php sessions that I need to include the code <br /> <br /><?php<br />session_start(); // start up your PHP session! <br />?> <br /> <br />at the beginning of the page before all the HTML code <br /> <br />And that I use the extra code ... this is only example code from a tutorial I am using not my variables <br /> <br /><?php<br />session_start(); <br />$_SESSION['views'] = 1; // store session data<br />echo "Pageviews = ". $_SESSION['views']; //retrieve data<br />?> <br /> <br />So i need want to store my idartist_pnt variable in the session so I put .... change the code to <br /> <br /><?php<br />session_start(); <br />$_SESSION['artist_pnt']<br />echo "idartist_pnt = ". $_SESSION['idartist_pnt']; //retrieve data<br />?> <br /> <br />Does that sound correct? <br /> <br />anyway I try to put all this code into my pages and on my index page .... that lists all the artists I can insert the code ....... <br /> <br /> I assume that the code stores the id of the artist that I click on ??? Is that correct? <br /> <br />Then I think I need the same code on the painting gallery page so i insert the same code as above then I change the recordset on the painting gallery page to filter by session variable idartist_pnt = idartist_pnt......... and then I test and i get nothing.....? <br /> <br />I then go to my getpicsidartist.php page the page with the xml data feed and I try to insert the code at the top of the page and I get this error 'Cannot modify header information - headers already sent by ........' <br /> <br />So I find the 'header' part of the code .......which is on line 51..... header("Content-type: text/xml"); and I try to paste the code bellow that and get more and more errors....... <br /> <br />Am i on the right track .... is this the correct code I need... <br /> <br /><?php<br />session_start(); <br />$_SESSION['artist_pnt']<br />echo "idartist_pnt = ". $_SESSION['idartist_pnt']; //retrieve data<br />?> <br /> <br />Do I need this code on all of my pages ..... index artist gallery and the getpic page ? <br /> <br />i am really confused ..... <br /> <br />Any help or info about how to make this work would be great..... <br />Once I can do it once I will know how to do it for many of my pages... <br /> <br />Thanks again <br /> <br />have a great day <br /> <br />Bibi
            • 3. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
              mrcharis2003@yahoo.c Level 1
              Oh and I have tried to insert a session variable from the bindings panel and gone to all the adobe help pages to find out how to get it to work and I still cant.....

              Thanks again....
              • 4. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                mrcharis2003@yahoo.c Level 1
                Hi there <br /> <br />Ok i was on the wrong track...... I think... <br /> <br />I have been reading a lot today and I understand a little more how to start and use sessions..... there were some small sections , about a page in a book I have that describes how to start a session creating and destroying sessions .... but it does not go into any detail at all ..... <br /> <br />It says to use session_start(); to start a session ok easy enough <br /> <br /> and to use $_SESSION['MY INFO HERE'] to start a session <br /> <br />but that this is only used when the 'name' is put into a form <br /> <br />and that this information is displayed on any page that has session_start() <br /> <br />I think I understand what you said in your reply a little better now <br /> <br />That I only need to start a session on my detail page... to store the passed variable from the master page? ....is that correct.... <br />Is this the code I need.....? <br /> <br /><?php<br />session_start();  <br />$_SESSION['idartist_pnt'] = 'idartist_pnt';<br />?> <br /> <br />I am thinking that this piece of code will get and store the variable that was passed from the master page... eg...http://localhost/mygallery/productgallery.php?idartist_pnt=7 <br /> <br />Is that correct? <br /> <br />And then I need to put <br /> <br /><?php<br />session_start(); <br />$_SESSION['idartist_pnt'];<br />?> <br /> <br />at the beginning of my get_pic page??? then filter the recordset by session variable??? <br /> <br />I have tried all this and it still does not work ..... <br /> <br />Any idea how I can make this work..... <br /> <br />When I put..... $_SESSION['MY INFO HERE'] what do I need to add to make id grab the passed URL variable ??? <br /> <br />Anyway I am getting there slowly but very frustrating..... <br />Any help would be great <br />Have a nice day
                • 5. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                  Günter Schenk Level 4
                  hi charis, <br /> <br />------ <br />That I only need to start a session on my detail page... to store the passed variable from the master page? ....is that correct <br />----- <br /> <br />yes, something like the following, which should be put on line 1 of your detail page: <br /> <br /><?php<br />if(!empty($_GET['idartist_pnt'])){<br />session_start();<br />$session_idartist_pnt = mysql_real_escape_string($_GET['idartist_pnt']);<br />$_SESSION['session_idartist_pnt'] = $session_idartist_pnt;<br />}<br />?> <br /> <br />now that the new session variable "session_idartist_pnt" has been established plus has captured the value of your URL parameter "idartist_pnt", this session variable should be available in your dynamic XML file as well -- of course only if you add "session_start();" to this file too, otherwise it won´t be able to detect the session. <br /> <br />Cheers, <br />Günter Schenk <br />Adobe Community Expert, Dreamweaver
                  • 6. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                    mrcharis2003@yahoo.c Level 1
                    Hi there

                    Wow thanks soo much for your effort I can only understand about 10% of the code you wrote but it is a good starting point for me to learn more.....

                    I think I have done everything you said ..... I inserted the code you gave me into line 1 of my productgallery page and inserted a session_start(); in my php xml get_pic page

                    Then when I test I get these two errors

                    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\mygallery\productgallery.php on line 1

                    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\wamp\www\mygallery\productgallery.php on line 1

                    So I google it and find out ..... not much just that i am not connecting to my database and no idea why my user name changed to 'ODBC'

                    I then tried to insert the



                    before the code yuo supplied but then the page works but still no data from the getpic.php page

                    Any idea why? the complete code I inserted with the my connection to my database is as follows



                    The database connection is working fine it works 100% but not after I insert the other code

                    Thanks again for all your help i think that this is a really usefull function and I really appreciate any time you have spent helping me

                    Have a great day
                    • 7. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                      Günter Schenk Level 4
                      Hi Charis, <br /> <br />that´s true, the function "mysql_real_escape_string" requires a valid connection which you actually don´t even need in this case -- however, as the main point of this function is to help "sanitizing" the URL variable´s value, we can also replace it with another native PHP function which does not require a database connection: "is_numeric". <br /> <br />Here´s a slightly modified version of my code, which now uses the "is_numeric" function: <br /> <br /><?php<br />if (!empty($_GET['idartist_pnt']) && is_numeric($_GET['idartist_pnt'])){<br />session_start();<br />$session_idartist_pnt = $_GET['idartist_pnt'];<br />$_SESSION['session_idartist_pnt'] = $session_idartist_pnt;<br />}<br />?> <br /> <br />Works better now ? <br /> <br />Cheers, <br />Günter Schenk <br />Adobe Community Expert, Dreamweaver
                      • 8. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                        mrcharis2003@yahoo.c Level 1
                        Hi there <br /> <br />Thanks for your updated code I don't get anymore errors <br /> <br />But.... still not working..... <br /> <br />So far..... <br /> <br />I have my index page working and it passes the correct idartist_pnt to the gellery page the gallery page then displays the painings of that artist so I know is all working....... <br /> <br />I have put all the code you gave me carefully at the top of my gallery page....as follows <br /> <br /><?php if (!empty($_GET['idartist_pnt']) && is_numeric($_GET['idartist_pnt'])){ session_start(); $session_idartist_pnt = $_GET['idartist_pnt']; $_SESSION['session_idartist_pnt'] = $session_idartist_pnt; } ?><?php require_once('Connections/mygallery.php'); ?> <br /><?php<br /><br />including the connection to the database<br /><br />and when I test I get no errors   <br /><br />But the flash slideshow is still not retrieving any pics from my   getpic.php page<br /><br />I have put  <?php session_start(); ?> at the top of the getpic.php page so it looks like this... <br /> <br /><?php session_start(); ?> <br /><?php require_once('Connections/mygallery.php'); ?> <br />
                        • 9. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                          Günter Schenk Level 4
                          ------
                          And then filtered the recordset on that page by session variable artistid_pnt = artistid_pnt
                          ------

                          I don´t know what that means, but the session variable to check should be "session_idartist_pnt" only

                          Cheers,
                          Günter Schenk
                          Adobe Community Expert, Dreamweaver
                          • 10. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                            mrcharis2003@yahoo.c Level 1
                            Wow

                            Thankyou sooooo much

                            I followed your insrtuctions to change the recoredset filter to session_idartist_pnt and it worked......

                            I am sooo happy I have wanted to be able to add this feature to my web sites for years..... well about a year......

                            ADDT is awesome

                            My gallery site is coming along great ..... I can add a new artist from a form..... choose to add that artists name into a submenu on my index page (using mx css menu.... great extension).... then add pictures from a form that I can choose the correct artist from a dropdown menu... all dynamic.....

                            Then click on an artist name and be taken to their gallery page that displays all their pictures and now..... thanks to you ... I have a dynamic xml flash slideshow on the same page.....that uses the same pictues of that artist..... all automated..

                            Amazing stuff

                            Thank you sooooo much you really made my day..... I was absolutly lost in how to do this by myself I found nearly nothing that could help on the net or in my books.....

                            Thanks again keep up the good work...

                            have a great day

                            bibi
                            • 11. Re: How do I pass a url variable to an php XML page to feed a dynamic slideshow with records filtered by
                              Günter Schenk Level 4
                              Hi Charis,

                              ------
                              bibi
                              ------

                              ...or bibi then :-)

                              I´m very happy to see that it works, and...

                              ---------
                              thanks to
                              ---------

                              ...your will to experiment with such weird suggestions you managed to get it done -- good job !! :-)

                              ---------------
                              ADDT is awesome
                              ---------------

                              I agree, and even though I´m using it for years now I still discover new ways to get things done -- and as you can see, extending one´s PHP skills definitely helps too, as not everything can be achieved with ADDT´s on-board functionality only. But fortunately the developers have implemented some "spots" where you can define your own actions, e.g. Custom Triggers or Transactions, and this is a very powerful feature that´s still underestimated by many users.

                              BTW, once your gallery site is done, I´d like to see what it looks like -- can you post a link then ?

                              Cheers,
                              Günter Schenk
                              Adobe Community Expert, Dreamweaver