Jump to content

[SOLVED] problem with classified advert script


joshgarrod

Recommended Posts

Hi everyone, I am trying to write a classified advrt script. So far I have managed to retrieve and display all of the information I want to in the list, however, I cant get my "more info" link to work to enable a click through to the page where you see all the information about the item. I know it is something stupid but I can't see it. Can any body help? Thanks in advance....

 

<?php
		mysql_connect("213.171.200.50", "usr", "pass") or die(mysql_error()); 
		mysql_select_db("db") or die(mysql_error()); 

		$cond = "";

		if(isset($_POST['x']) && is_numeric($_POST['x']))
		{
			$x = intval($_POST['x']);
			$cond = " WHERE weight <= {$x}";
			echo "You entered " .$x. "kg";
		}

		$data = mysql_query("SELECT * FROM table".$cond);

		while($info = mysql_fetch_array( $data )) 
		{ 
			$i=0;
			$ref=mysql_result($info,$i,"ref");
			Print "<div id=\"caravan_row\">";
				Print "<div id=\"logo\"><img src=\"images/".$info['make'] . ".gif\" /></div>";
				Print "<div id=\"image\"><img src=\"".$info['image'] . "\" /></div>";
				Print "<div id=\"specifications\">";
					Print "<div id=\"make\"><h1></strong>".$info['make'] . " " . $info['model'] ."</h1></div>";
					Print "<div id=\"price\"><span class=\"price\">£".$info['price'] . "</span></div>";
					Print "<div id=\"year\"><strong>Year: </strong>".$info['year'] . " </div>";
					Print "<div id=\"weightun\"><strong>Unladen weight: </strong>".$info['weightun'] . "kg</div>";
					Print "<div id=\"berth\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" />" .$info['berth'] . " berth</div>";
					Print "<div id=\"weightla\"><strong>Laden weight: </strong>".$info['weightla'] . "kg</div>";
					Print "<div id=\"lengthex\"><strong>Shipping length: </strong>".$info['lengthex'] . "ft</div>";
					Print "<div id=\"more\"><a href='view_used_caravan&caravan=$ref'>More info>></a></div>";

				Print "</div>";
			Print "</div>";
		}

		?>

I have been trying to fix it while I am waiting and I think I am a bit closer.

 

I am receing this error:

Parse error: parse error, unexpected $end in file\path\www\website\view_used_caravan.php on line 78
but line 78 is the </html> tag???

 

Here is the code for the page with all of the listings:

 

<?php
		mysql_connect("serv", "usr", "pass") or die(mysql_error()); 
		mysql_select_db("db") or die(mysql_error()); 

		$cond = "";

		if(isset($_POST['weight']) && is_numeric($_POST['weight']))
		{
			$weight = intval($_POST['weight']);
			$cond = " WHERE weightla <= {$weight}";
		}

		$data = mysql_query("SELECT * FROM classifieds".$cond);
		while($info = mysql_fetch_array( $data )) 
		{ 

			Print "<div id=\"caravan_row\">";
				Print "<div id=\"logo\"><img src=\"images/".$info['make'] . ".gif\" /></div>";
				Print "<div id=\"image\"><img src=\"".$info['image'] . "\" /></div>";
				Print "<div id=\"specifications\">";
					Print "<div id=\"make\"><h1></strong>".$info['make'] . " " . $info['model'] ."</h1></div>";
					Print "<div id=\"price\"><span class=\"price\">£".$info['price'] . "</span></div>";
					Print "<div id=\"year\"><strong>Year: </strong>".$info['year'] . " </div>";
					Print "<div id=\"weightun\"><strong>Unladen weight: </strong>".$info['weightun'] . "kg</div>";
					Print "<div id=\"berth\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" />" .$info['berth'] . " berth</div>";
					Print "<div id=\"weightla\"><strong>Laden weight: </strong>".$info['weightla'] . "kg</div>";
					Print "<div id=\"lengthex\"><strong>Shipping length: </strong>".$info['lengthex'] . "ft</div>";
					Print "<div id=\"more\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'>More info>></a></div>";

				Print "</div>";
			Print "</div>";
		}
		?>

 

And here is the code for the page to view more info on a specific item:

 

<?php
		$con = mysql_connect("serv","usr","pass");
		if (!$con)
			{
			  die('Could not connect: ' . mysql_error());
			 }

			mysql_select_db("db", $con);

			$page = $_GET['ref']; // This will be the ID of the page
			$page = mysql_real_escape_string(strip_tags($page));

			  $query = mysql_query("SELECT * FROM classifieds WHERE `ref` = '$page'");

			   if(mysql_num_rows($query)==0){

				die("Sorry, but the page doesnt exist!");

				  }else{

					while($info = mysql_fetch_array($query)){

				  echo "<div id=\"make\">" . $info['make'] . "</div>";

			?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.