drwael 0 Report post Posted October 4, 2006 hi everybody,i am new to php programming,i have this code in page number 1: <?php $pages = array( 'number1' => 'number1.php', 'number2' => 'number2.php', 'number3' => 'number3.php', 'number4' => 'number4.php', ); if (isset($_GET['page']) && isset($pages[$_GET['page']])) { include($pages[$_GET['page']]); } else { include($pages['number1']); }?> but i dont want to have 4 pages called number1, number2, number3, number4i wanna have just 1 page that have a code like this:<?php$number1 = "<img src=\"images/number1.gif\" width=\"57\" height=\"171\" alt=\"\">";$number2 = "<img src=\"images/number2.gif\" width=\"57\" height=\"171\" alt=\"\">";$number3 = "<img src=\"images/number3.gif\" width=\"57\" height=\"171\" alt=\"\">";$number4 = "<img src=\"images/number4.gif\" width=\"57\" height=\"171\" alt=\"\">";?> so how can i include that second page through the first code?thanks for your time Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted October 4, 2006 Have a look here at the w3school site. They have a basic introduction to php coding and the syntax for php language. You may be able to find what you need on that site. I don't quite follow exactly what it is you are trying to do using the code example you posted. Perhaps if you explained it a little better using words instead of the code, someone might be able to assist you. In the meantime, read up on the include function at the site I added above. Share this post Link to post Share on other sites
shadowx 0 Report post Posted October 5, 2006 Hi there, like jlhaslip im not entirely sure what youre after but ill take a shot and hpefully i can help abit. i think i get what you mean. for example with the image code you posted you want the imnage to change depending on what the user inputs? so you could have a link that goes to a page like https://www.salesforce.com/products/platform/overview/page1.php?image=1 and image one would be loaded up, but if they clicked a link like https://www.salesforce.com/products/platform/overview/=2 image two would be shown? right? if so you could do what i have done on my website. First of all follow the link given to you and learn about the include function. it will make things easier to learn and understand. then you would need code something like: (assuming that you use the url like https://www.salesforce.com/products/platform/overview/page1.php?image=1) //get the value in the url into a variable$image = $_GET['image'];//use include to put this file onto page1.phpinclude($image); im not sure how well include handles images as ive only ever used it to include php and html files. but if you wanted to use this to load different content (eg like Xisto.com does with index.php?act=something and load a different content depending on the act. EG act=post lets the php know its looking at a forum post.) then you would use the code above but add something to it like: //get the value in the url into a variable$image = $_GET['image'];// add ".html" to filename$html = ".html";$image = "$image$html";//now $image is something like 1.html//use include to put this file onto page1.phpinclude($image); so if 1.html was a picture gallery the user would see a picture gallery. And if 2.html was a contact form they would see the contact form. for better explainations check the link given to you, i just hope this is easier to understand because i sometimes find php manuals and such like to be hard to understand. Share this post Link to post Share on other sites
electron 0 Report post Posted October 5, 2006 You can have everything in just one page.Use an array the way you did in the case of the array you build of all the files.So the array would look like this: <?php$number['number1'] = "<img src=\"images/number1.gif\" width=\"57\" height=\"171\" alt=\"\">";$number['number2'] = "<img src=\"images/number2.gif\" width=\"57\" height=\"171\" alt=\"\">";$number['number3'] = "<img src=\"images/number3.gif\" width=\"57\" height=\"171\" alt=\"\">";$number['number4'] = "<img src=\"images/number4.gif\" width=\"57\" height=\"171\" alt=\"\">";?> Now just use you if condition and call the Variable you got.That was easy and you dont need to include a file for that.However if you wanted to include then first include and then use array.Hope that helps Share this post Link to post Share on other sites