Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. I'm watching this thread for a solution, but unable to provide one I'm afraid :( Huggie
  2. That's perfect, I'm only matching on a single line and I certianly don't want to use the /s modifier. Regards Huggie
  3. Effigy, that's what I had, I copied and pasted it direct from the script. It's an issue with putting the [ php ] [ /php ] tags around it, they stripped it out. Huggie
  4. Oh right, what does the pages table contain then? Huggie
  5. OK, I remember, I'm guessing you only have one page at the moment though?  If you had more than one page you'd have come up against this sooner. The problem you have is that you want the content for every page on pages.php and then just to include that in the rest of the pages across the site.  If that's the case then you need lots of conditional IF statements on pages.php like I mentioned earlier. Create hotels.php and include pages.php on it.  Then change the links in index.php [b]From:[/b][code=php:0] <a href="{$_SERVER['PHP_SELF']}?id={$row['Id']}">{$row['regionName']}</a><br> [/code] [b]To:[/b][code=php:0] <a href="pages/hotels.php?id={$row['Id']}">{$row['regionName']}</a><br> [/code] This should still work with the index.php and pages.php that I provided in the earlier post. Huggie
  6. You can just echo it... [b]index.php[/b] [code] <?php $msg = "<html><body><center>Hello</center></body></html>"; echo $msg; ?> [/code] Huggie
  7. This maybe better placed in the [url=http://www.phpfreaks.com/forums/index.php/board,58.0.html]Application Design[/url] board on this forum. This board is specifically for php help.  If I find any tutorials, I'll post them for you :) Regards Huggie
  8. Do you have individual navigation/design elements on seperate pages that you include? e.g Index.php includes header.php, navigation.php, sidebar.php etc. If so, then create a new page called hotellist.php with ecah of those elements on it and still include pages.php for the content. Huggie
  9. Thanks matey... That's cleared it up. Huggie
  10. I didn't see that... It doesn't make sense now.  In one post you said this: [quote] Also a quick question, what include would i put on the index page for the hotels page, i would use this normally because i put most things in one page [/quote] Now you're saying: [quote] there is still a problem, which is, thi results now appear on the index page, or the home page when you click on the link, instead of  it being on its own page [/quote] Tell me what you want on each page and we'll work out how you need to do it. Huggie
  11. ok, create the following three new pages and tell me if it works as expected: [b]index.php[/b][code] <?php include('connect.php') // This is the name of your db connection file include('/pages/page.php'); ?> [/code] [b]pages.php[/b] - In the pages directory[code] <?php $sql="SELECT c.countryName, r.regionName, r.Id FROM tabCountry c, tabRegion r WHERE c.Id = r.countryId"; $result = mysql_query($sql); if (!$result) {   die('Invalid query: ' . mysql_error()); } $country = "null"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   $cheader = $row['countryName'];   if (is_null($country) || strcmp($country,$cheader) !=0){       $country = $row['countryName'];       echo <<<HTML         <br>         <h2>$country</h2> HTML;   } echo <<<HTML   <a href="{$_SERVER['PHP_SELF']}?id={$row['Id']}">{$row['regionName']}</a><br> HTML; } if (isset($_GET['id']){   $id = $_GET['id'];   include('hotel.php'); } ?> [/code] [b]hotel.php[/b] - In the pages directory along side pages.php[code] <?php $sql="SELECT * FROM tabHotel WHERE regionId = $id"; $result = mysql_query($sql); if (!$result) {   die('Invalid query: ' . mysql_error()); } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   $name = $row['hotelName'];   $description = $row['hotelDescription'];   $rating = $row['hotelRating'];   // List the hotels   echo "$name - $rating - $description<br>\n"; } ?> [/code] If you then goto index.php you should get a list of countries and their regions listed below.  When you click on one of the regions, index.php should reload with the same list of countries and regions, but also the hotels you selected below them. Regards Huggie
  12. Nested ternary operator's huh... I'll have to be careful here, but that worked thanks Jenk. Can you possibly show me what this would look like if it was a nested 'if' statement, to help me better understand? Huggie
  13. You will need to include the path in the include yes. As for the error, I'm assuming your include structure is like this... [b][color=green][pre] |- index.php -|               |- include(pages.php) - |                                       |- include(hotel.php) [/pre][/color][/b] So your index.php includes pages.php (which happens to be in a seperate directory named pages) and pages.php includes hotel.php (which is in the same directory as pages.php). Is this correct? Regards Huggie
  14. Thanks for that SA, I didn't notice that, but have corrected that now. Any ideas on my define problem? Huggie
  15. Try removing one of the [color=red][b]}[/b][/color] from the end of the file. Regards Huggie
  16. We're here to help you with any specific php problems you're having.  If you're after someone to help you complete the project, an extra pair of hands as it were, then you'd be better off posting it in the Freelance board on this forum. If however there's something that you can't quite get your head around then post it here and we'll (more than likely) help you to get it sorted  ;) Regards Huggie
  17. Change this: [code=php:0]if (isset($_GET['id']){[/code] to this: [code=php:0]if (isset($_GET['id'])){[/code] <- Notice the extra parenthesis If this was in the code I wrote, I apologise. Regards Huggie
  18. It should be fine, so long as $user on the previous page had something assigned to it. You might want to include a few more parameters in your call to setcookie() though.  Like 'path' and 'domain' Regards Huggie
  19. In an attempt to write good code, I'm going to put [code=php:0]error_reporting(E_ALL);[/code] on all my pages. I'd like to know how to define a variable.  I thought that you just had to assign something to it? I'm getting the following error on my page: [code]Notice: Undefined variable: bg in /home/domains/dizzie.co.uk/user/htdocs/php/pages.php on line 39[/code] Now line 39 looks like this: [code]$bg = ($bg == "#CCFF99" ? "#CCCC99" : "#CCFF99");[/code] Now the first $bg is attempting to have something assigned to it, I'm assuming it's the 2nd $bg in that row that php has the problem with, but don't know how to get around this.  If I just add [code=php:0]$bg = "null";[/code] on the line before it, it's fine, but is there a better way to do this? Regards Huggie
  20. It does, but I think you're getting slightly confused.  Once a page is 'included' it becomes part of the page it's being included in. if I have index.php like this: [code] <?php include('header.php'); echo <<<HTML; <body> </body> <html> HTML; ?> [/code] and header.php looks like this: [code] <?php echo <<<HTML <html> <head>   <title>This is index.php</title> </head> HTML; } [/code] The resulting code for index.php is: [code] <html> <head>   <title>This is index.php</title> </head> <body> </body> <html> [/code] It treats all the includes as 'one page'.  So it's no big deal really which page you have it on, if pages/page.php has all the code on it, then by all means include it on there.  You still have to capture the 'id' from the URL and specify where on the page you want the list of hotels displayed. Regards Huggie
  21. OK, still have this code on the index.php (note, I've changed the link at the bottom of the page to call the current page. [code] <?php $sql="SELECT c.countryName, r.regionName, r.Id FROM tabCountry c, tabRegion r WHERE c.Id = r.countryId"; $result = mysql_query($sql); if (!$result) {   die('Invalid query: ' . mysql_error()); } $country = "null"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   $cheader = $row['countryName'];   if (is_null($country) || strcmp($country,$cheader) !=0){       $country = $row['countryName'];       echo <<<HTML         <br>         <h2>$country</h2> HTML;   } echo <<<HTML   <a href="{$_SERVER['PHP_SELF']}?id={$row['Id']}">{$row['regionName']}</a><br> HTML; } ?> [/code] Then where you want your list of hotels to appear on your index.php page, have this: [code] if (isset($_GET['id']){   $id = $_GET['id'];   include('hotel.php'); } [/code] and your hotel.php looks like this: [code] <?php $sql="SELECT * FROM tabHotel WHERE regionId = $id"; $result = mysql_query($sql); if (!$result) {   die('Invalid query: ' . mysql_error()); } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   $name = $row['hotelName'];   $description = $row['hotelDescription'];   $rating = $row['hotelRating'];   // List the hotels   echo "$name - $rating - $description<br>\n"; } ?> [/code] Regards Huggie
  22. Morning all, I have the following expression which I think works well.  What I want in short is a string to start and end with the same character, with atleast one thing in between. [code=php:0]/^(.).+\1$/ [/code] Below is the details of what I think the above does, but wondered if there's a better way to do it... 1. Start at the beginning of the line 2. Capture the first character, doesn't matter what it is 3. Then there has to be another character, again, doesn't matter what, but has to be atleast one 4. Then an identical character to the first 5. Then the end of the line Regards Huggie
  23. Thanks effigy... I have another question, but I'll post it in a new topic with a new title. Regards Huggie
  24. What was it Itoto? Regards Huggie
  25. According to the PHP manual, the following code should produce "Matched". [code] <?php $string = "sense and sensibility"; if (preg_match("/(sens|respons)e and \1ibility/", $string)){ echo "Matched"; } else { echo "No match made"; } ?> [/code] But it doesn't.  It tells me, No match made.  Anyone tell me if I'm missing something here?  Have I overlooked something obvious.  Can I only use back referencing in certain versions of PHP? Regards Huggie
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.