illuz1on Posted March 9, 2007 Share Posted March 9, 2007 Hey, I have a problem which I havent been able to overcome, and its killing me!! Please can someone help me fix this piece of code - When beaches.php is reached i want it to display the list of beaches, and when one of those beaches is clicked it displays the 'more info' of that specific beach. And then has a link back to beaches.php to see the list again. Would love any suggestions! Thanks <?php require_once('db.php'); if (isset($_GET['view'])) { $sql = "SELECT * FROM beaches"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name2 = $record['name']; $picture = $record['picture']; $rating = $record['rating']; $desc = $record['desc']; echo "$id, $name2, $picture, $rating, $desc"; } ?> <font class="header">Cape Town Beaches</font><br> <br> <?php $sql = "SELECT * FROM shops"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { echo "<a href="beaches.php?view=$id&name=$name2"><$name2><br></a>"; } ?> Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/ Share on other sites More sharing options...
Orio Posted March 9, 2007 Share Posted March 9, 2007 So... What's the problem with the script? Orio. Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-203406 Share on other sites More sharing options...
JasonLewis Posted March 9, 2007 Share Posted March 9, 2007 echo "<a href="beaches.php?view=$id&name=$name2"><$name2> </a>"; to this: echo "<a href='beaches.php?view={$id}&name={$name2}'>{$name2}</a>"; Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-203411 Share on other sites More sharing options...
illuz1on Posted March 9, 2007 Author Share Posted March 9, 2007 Thanks for the quick response... I tried putting that line in and .. Parse error: parse error, unexpected $ in /home/capetown/public_html/beaches.php on line 30 Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-203417 Share on other sites More sharing options...
redarrow Posted March 9, 2007 Share Posted March 9, 2007 <?php require_once('db.php'); if (isset($_GET['view'])) { $sql = "SELECT * FROM beaches"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name2 = $record['name']; $picture = $record['picture']; $rating = $record['rating']; $desc = $record['desc']; echo "$id, $name2, $picture, $rating, $desc"; } ?> <font class="header">Cape Town Beaches</font> <?php $sql = "SELECT * FROM shops"; $data = mysql_query($sql); while($rec = mysql_fetch_assoc($data)) { $id = $rec['id']; $name2 = $rec['name']; echo "<a href='beaches.php?view=$id&name=$name2'><$name2> [/url]"; } ?> Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-203441 Share on other sites More sharing options...
illuz1on Posted March 9, 2007 Author Share Posted March 9, 2007 Still getting the same error Parse error: parse error, unexpected $ in /home/capetown/public_html/beaches.php on line 37 Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-203631 Share on other sites More sharing options...
JasonLewis Posted March 10, 2007 Share Posted March 10, 2007 try this: <?php require_once('db.php'); if (isset($_GET['view'])) { $sql = "SELECT * FROM beaches"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name2 = $record['name']; $picture = $record['picture']; $rating = $record['rating']; $desc = $record['desc']; echo "$id, $name2, $picture, $rating, $desc"; } ?> <font class="header">Cape Town Beaches</font> <?php $sql = "SELECT * FROM shops"; $data = mysql_query($sql); while($rec = mysql_fetch_assoc($data)) { $id = $rec['id']; $name2 = $rec['name']; echo "<a href='beaches.php?view=$id&name=$name2'><$name2> [/url]"; } } ?> Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-204023 Share on other sites More sharing options...
legohead6 Posted March 10, 2007 Share Posted March 10, 2007 this <?php require_once('db.php'); if (isset($_GET['view'])) { $sql = "SELECT * FROM beaches"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name2 = $record['name']; $picture = $record['picture']; $rating = $record['rating']; $desc = $record['desc']; echo "$id, $name2, $picture, $rating, $desc"; } } ?> Link to comment https://forums.phpfreaks.com/topic/41950-can-anyone-see-the-problem/#findComment-204038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.