Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. Sure... bighuggybear (at) hotmail (dot) co (dot) uk Huggie
  2. Can you actually show me the php? I need to see what's going in and coming out of the database. Cheers Huggie
  3. I see quite a lot of code on these forums that does the same thing but is written differently... e.g. When referencing a GET variable in PHP I use $_GET['name'].  If I try and use this exact var in a heredoc it doesn't work, I have to drop the single quotes and use $_GET[name], now I've also seen people put it as {$_GET['name']}. Now I can't find anything about these curly braces in the manual and I'd like to try and work to some kind of a standard, so does anyone have an explanation or can you point me to the page in the manual where it's listed? Regards Huggie
  4. Try putting the [code=php:0]$results = mysql_query($sql); [/code] Inside the foreach loop. Regards Huggie
  5. OK, so we know it's getting the right id... So on your hotel.php, if you type this: [code] <?php   $id = $_GET['Id'];   echo $id; ?> [/code] Does it echo the correct values... Try clicking a couple of regions from the previous page. Huggie
  6. If you right click on the page that has the list of countries and regions and then view the source.  Does the <a href... link look correct? Does it say something like [code=php:0]<a href="../pages/hotels.php?id=5">Greece</a> [/code] Huggie
  7. Here's what I have that works, but I wondered if there's an easier way? [code]<?php   // Connect to my db   include('connect.php');     // Get url params for the 'order by' if they're set   if (isset($_GET['orderby']) && isset($_GET['orderdir'])){   $orderby = $_GET['orderby'];   $orderdir = $_GET['orderdir'];   }   // Select all my records   $sql = "SELECT * FROM tblCountry";     // If 'order by' was set then concatenate the string   if ($orderby){   $sql .= " ORDER BY $orderby $orderdir";   }   // Execute the SQL result   $result = mysql_query($sql);   if (!result){       echo "There was a problem selecting the countries" . mysql_error();   }     // Decide what the last link pressed was and then change the next link accordingly   $orderdir = ($orderdir == "desc") ? "asc" : "desc";   // Here's where I output my column headings with the links   echo <<<HTML <table width="300"> <tr>   <td bgcolor="#000000">   <table width="300" cellpadding="2" cellspacing="1" border="0">     <tr bgcolor="#FFFFFF">     <td width="75" align="center"><a href="datatab.php?orderby=countryID&orderdir=$orderdir">ID</a></td>     <td width="225" align="center"><a href="datatab.php?orderby=countryName&orderdir=$orderdir">Country</td>     </tr> HTML;   while($row = mysql_fetch_array($result, MYSQL_ASSOC)){       $id = $row['countryID'];       $country = $row['countryName'];       echo <<<HTML     <tr bgcolor="#FFFFFF">     <td width="75" align="center">$id</td>     <td width="225" align="left">$country</td>     </tr> HTML; }   echo <<<HTML   </table>   </td> </tr> </table> HTML; ?> [/code] You can see what it looks like here: [url=http://dizzie.co.uk/php/datatab.php]Dizzie.Co.Uk[/url] Regards Huggie
  8. hotels.php needs the following: [code] <?php $id = $_GET['Id']; $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] Huggie
  9. Does anyone know if there's a tutorial which shows you how to 'order by' a particular column? I'm going to have my data displayed in a table like this: [table] [tr][td]ID[/td][td]Country[/td][/tr] [tr][td]1[/td][td]England[/td][/tr] [tr][td]2[/td][td]Ireland[/td][/tr] [tr][td]3[/td][td]Scotland[/td][/tr] [tr][td]4[/td][td]Wales[/td][/tr] [/table] I want the user to be able to click on the column heading and it will sort it oposite to how it's currently sorting it, similar to [url=http://www.ebuyer.com/customer/search/?strSearch=&intSubcatUID=849&bolShowAll=true&intMfrID=411]this page[/url].  If you click on the price heading it sorts it either ascending or descending, based on how it's currently displayed. I've been messing about and haven't really come close.  I'll post some code examples shortly. Regards Huggie
  10. Thanks for posting back phpORcaffine. Huggie
  11. Did you have any code for a hotel page yet?  I don't think I've seen any... It might be an idea to mork this thread as solved and then start a new one with any hotel related pages, as this is getting quite long now. Huggie
  12. I hope so ;) Well done for persevering. Huggie
  13. They're table aliases... Because we're joining to another table, it's shorter than specifying the whole table name. Rich
  14. ok, add error checking then... [code]<?php // Your select to get all the data, I've tried to remember your column/table data $sql="SELECT c.countryName, r.regionName, r.regionID FROM tblCountry c, tblRegion r WHERE c.countryID = 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="hotels.php?regionid=$row[regionID]">$row[regionName]</a><br> HTML; } ?>[/code] Regards Huggie
  15. Oh, I see, you want to add the cookie after they've logged in to say they've logged in. In that case, set something like this: [code] <?php // Cookie parameters $name = "authenticated"; $value = "y"; $path = "/";  // This specifies where the cookie will be valid from.  / (forward slash) is root $domain = "yourdomian.com";  // This will make the cookie available to the whole domain $expire = time() +3600;  // Set the cookie to expire in an hour setcookie($name, $value, $expire, $path, $domain);  // Set the actual cookie ?> [/code] Then at the top of your pages: [code] <?php if ($_COOKIE['authenticated'] != "y"){ header("Location: login.php"); } else { // Your page content here } ?> [/code] Regards Huggie
  16. ok, try replacing all of your code that gets the countries and regions with this: [code] <?php // Your select to get all the data, I've tried to remember your column/table data $sql="SELECT c.countryName, r.regionName, r.regionID FROM tblCountry c, tblRegion r WHERE c.countryID = r.countryID"; $result = mysql_query($sql); $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="hotels.php?regionid=$row[regionID]">$row[regionName]</a><br> HTML; } ?> [/code] See example here: http://www.dizzie.co.uk/php/pages2.php Regards Huggie
  17. oh ok, my bad.  I'm looking again now. Rich
  18. That's not correct... The SQL statement that selects the total records needs to reflect your original select.  So for you, you need to change this: [code=php:0]$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM venues WHERE auth = 1"),0); [/code] To this: [code=php:0]$total_results = mysql_result(mysql_query("SELECT COUNT(*) as NUM FROM venues WHERE county = $cid"),0); [/code] Regards Huggie
  19. Jenk's code will also work, but does something else behind the scenes that you aren't aware of. array_pop() actually removes the last item from the array.  So although you get the value that you're after returned.  Your $thefiles array now only contains 3 items instead of 4.... I think  :-\ Regards Huggie
  20. You need to use [url=http://www.php.net/manual/en/function.setcookie.php]setcookie[/url] create a cookie. [code] <?php // Cookie parameters $name = "username"; $value = "HuggieBear"; $path = "/";  // This specifies where the cookie will be valid from.  / (forward slash) is root $domain = "yourdomian.com";  // This will make the cookie available to the whole domain $expire = time() +3600;  // Set the cookie to expire in an hour setcookie($name, $value, $expire, $path, $domain);  // Set the actual cookie ?> [/code] Regards Huggie
  21. OK, there's no drop downs on that page at all... Huggie
  22. It is quite messy, but if you're new it's understandable, no doubt when I write my first proper php script it will be the same.  However, having said that, it looks as though the code itself is fine. I'm assuming this is a front page, or something similar? Do you have a URL where this is live, or are you testing locally?  If a live URL, can you provide it? Huggie
  23. Are you able to post the entire code from that page, I'd like to take a look at it if possible? Huggie
  24. Change this row: [code] $row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'regionName' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error()); [/code] To: [code] $row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'countryId' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error()); [/code] 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.