Jump to content

stu1040

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    London

stu1040's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, I’ve actually tried - While($row = mysql_fetch_assoc($result)) - The result is no data, and the address bar shows something is getting through but not displaying - locations.php?id=5' - These links go to the same page with the relevant data, such as london, birmingham. This is where the city links come from $data = mysql_query("SELECT id, location FROM cities GROUP BY location ORDER BY id ASC") OR DIE (mysql_error()); while($info = mysql_fetch_array($data)) Print "<a href=locations.php?id=".$info['id']."'>".$info['location'] ."</a><br />"; Loop for numbers, all the tutorials I find seem to use numbers as an example. And thanks for the update on mysql_real_escape_string
  2. Come on Guys and Girls! I’ve worked out the ‘while loop’ for numbers, it’s quite easy (when you know how). Being 42 (in 2 weeks) my brain is a little slow, and getting slower, (age). You can tell i’ve been working hard because i’m using a lot of brackets. Where am I going wrong? The code below comes from 5 distinct links of cities, birmingham, glasgow, london ... When I click the link such as ‘birmingham’ I arrive at a page where everything related to ‘birmingham’ should be displayed, and so to for the other cities. However only one record is being displayed when I know there are 3 records of each city. I’ve figured the ‘loop’ for numbers, but to get pacific related data i’m a little stumped. Guidance to any tutorials or direction appreciated, but no shouting since i’m simply learning. Thanks, Stuart. Laid out this way for easy reading. $id = mysql_real_escape_string(trim($_GET['id'])); $data = mysql_query("SELECT location FROM cities WHERE id = '$id' ") or die(mysql_error()); $info = mysql_fetch_array( $data ); While ??? { Print "".$info['location'] .""; }
  3. Thanks Blacknight, I'll try that.
  4. This one I have found useful. http://www.php-login-script.com/ AND http://www.formtools.org/ Hope this helps you.
  5. Why not contact your hosting firm? I had this problem and a simple email sorted it.
  6. Hi All. What should I be looking for if I want to display all relevant data from a clicked link. There are 5 cities. So if I click ‘birmingham’ then everything about birmingham would display, london and so forth on one page called ‘locations.php’ The links work fine below and display one city when clicked, when I know there are 3 of each in the database. I was thinking in the lines of a ‘while loop’ or similar! Wrong direction? locations landing page $id = mysql_real_escape_string(trim($_GET['id'])); $data = mysql_query("SELECT location FROM cities WHERE id = '$id' ") or die(mysql_error()); $info = mysql_fetch_array( $data ); { Print "".$info['location'] .""; } I have 5 x city links from this, works fine. $data = mysql_query("SELECT id, location FROM cities GROUP BY location ORDER BY id ASC") OR DIE (mysql_error()); while($info = mysql_fetch_array($data)) { Print "<a href=locations.php?id=".$info['id']."'>".$info['location'] ."</a><br />"; }
  7. Thanks. I removed distinct after playing around with it. What should I look for if I want to display everything to do with the link i’ve clicked. Such as clicked ‘london’ and everything related to london appeared, or ‘birmingham’ for example. So far the city appears once, but I require everything to do with that city to appear on the landing page, such as click birmingham and 3 x hotels appear in birmingham or london for example. Am I looking for a ‘while loop’ or similar? $id = mysql_real_escape_string(trim($_GET['id'])); $data = mysql_query("SELECT location, name FROM cities WHERE id = '$id' ") or die(mysql_error()); $info = mysql_fetch_array( $data ); { Print "".$info['location'] ." "; }
  8. Thanks for everyones input. It works. Stu. $data = mysql_query("SELECT DISTINCT id, location FROM cities GROUP BY location ORDER BY id ASC") OR DIE (mysql_error()); while($info = mysql_fetch_array($data)) { Print "<a href=locations.php?id=".$info['id']."'>".$info['location'] ."</a><br />"; } $id = mysql_real_escape_string(trim($_GET['id'])); $data = mysql_query("SELECT id, location FROM cities WHERE id = '$id' GROUP BY location ORDER BY id ASC") or die(mysql_error()); $info = mysql_fetch_array( $data ); { Print "".$info['location'] .""; }
  9. Thanks for your input. I’m not even sure what I should be googling, searching for to solve this problem. If I remove the ‘id’ from the SELECT DISTINCT then I get one of each city, but no data on the landing page. If I add ‘id’ to the SELECT DISTINCT then I get duplicate cities and data shows on landing page. Anyone know which direction I should be going, or what I should be studying? Thanks in advance. $data = mysql_query("SELECT DISTINCT id,location FROM cities ") OR DIE (mysql_error()); while($info = mysql_fetch_array($data)) { Print "<a href=locations.php?id=".$info['id']."'>".$info['location'] ."</a>"; } $id = mysql_real_escape_string(trim($_GET['id'])); $data = mysql_query("SELECT location FROM cities WHERE id = '".$id."'") or die(mysql_error()); $info = mysql_fetch_array( $data ); { Print "".$info['location'].""; }
  10. The first segment of code below displays 5 x DISTINCT cities that are ‘a href’ linked, when clicked will land on a page called locations.php. My problem is, no data displays on the locations page. I could create 5 x different pages, but what’s the point when the whole page format is the same. I’ve tried single quotes, and moving things about but I think it’s something to do with the landing page ‘id’. Any guidance, ideas appreciated. Thanks. LINKS PAGE $data = mysql_query("SELECT DISTINCT location FROM cities ") OR DIE (mysql_error()); while($info = mysql_fetch_array($data)) { Print '<p><a href=locations.php?id="'.$info['".$id."'].'">'.$info['location'] .'</a></p>'; } DATA LANDING PAGE $id = mysql_real_escape_string(trim($_GET['id'])); $data = mysql_query("SELECT location FROM cities WHERE id = '".$id."'") or die(mysql_error()); $info = mysql_fetch_array( $data ); { Print "".$info['location'].""; }
×
×
  • 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.