Jump to content

'GET' help!


phpwannabe25

Recommended Posts

I have a page where certain elements from a row are being read into the table on a page. when the user clicks on the row, it brings them to a new page, which should list out all the details from that row.

my problem is gettin the infomation specific from that row on to the next page...

 

here is the code from the first page....

 


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

mysql_select_db("db details", $con);
$county=htmlentities($_POST['county']);


$result = mysql_query("SELECT * FROM signuphotel where county='$county'");  

echo "<table id='myTable' cellpadding='0'>
<thead>
	<th axis='string'>Hotel Name</th>
	<th axis='string'>Address1</th>
	<th axis='string'>Address2</th>
	<th axis='string'>County</th>
	<th axis='string'>Hotel Star</th>
</thead>";
  
while($row = mysql_fetch_array($result))
{

echo "<tr onclick=\"window.location='viewhotel3.php?id=" . $row['id'] . "'\">";
  echo "<td>" . $row['hotelname'] . "</td>";
  echo "<td>" . $row['address1'] . "</td>";
  echo "<td>" . $row['address2'] . "</td>";
  echo "<td>" . $row['county'] . "</td>";
  echo "<td>" . $row['starrating'] . "</td>";   
  echo "</tr>";
  echo "</tbody>";
}  
  echo "</table>";
mysql_close($con);		
?> 	

 

the code for the following page is as follows:

 

<?php   

				 $id = $_GET["id"]; 


				 $con = mysql_connect("db details","db details","db details");
		if (!$con)
		 {
		 die('Could not connect: ' . mysql_error());
		 }


		mysql_select_db("db details", $con);


		$result = mysql_query("SELECT * FROM hotelsignup WHERE id = '$id'");


		echo "<table id='myTable' cellpadding='0'>
		<thead>
		<th axis='string'>Hotel Name</th>
		<th axis='number'>Address 1</th>
		<th axis='date'>Address 2</th>
		<th axis='date'>County</th>
		<th axis='number'>Telephone</th>
		<th axis='number'>Star rating</th>
		<th axis='number'>Hotel Overview</th>
		<th axis='number'>Hotel Facilities</th>
		<th axis='number'>Hotel Dining</th>
		</thead>";


		while($row = mysql_fetch_array($result))
		 {
		 echo "<tr onclick=\"window.location='viewhotel3.php?id=" . $row['id'] . "'\">";
						  echo "<td>" . $row['hotelname'] . "</td>";
						  echo "<td>" . $row['address1'] . "</td>";
						  echo "<td>" . $row['address2'] . "</td>";
						  echo "<td>" . $row['county'] . "</td>";
						  echo "<td>" . $row['telephone'] . "</td>";
						  echo "<td>" . $row['starrating'] . "</td>";
						  echo "<td>" . $row['hoteloverview'] . "</td>";
						  echo "<td>" . $row['hotelfacilities'] . "</td>";
						  echo "<td>" . $row['hoteldining'] . "</td>";
						echo "</tr>";
						echo "</tbody>";
		 }
		echo "</table>";


		mysql_close($con);

     ?>






 

any help would be appreiciated

Link to comment
Share on other sites

sorry

well basically, im asking is...

in the first page, i have pulled a few details from the row in the table. when the user clicks on this info, they are brought to a new page,where all the deatils from that row in the table will be displayed.

 

my problem is that i havin difficuly on the second page, gettin all the info from the selcted row displayed.

i have to pass through from the first page, the selected row and get all the info displayed from the table.

 

i am using the 'get' as below in the code, however this does not display the info, and if anyone can see problem with the code...

Link to comment
Share on other sites

This is an example of what SELECT query logic should look like.

 

You need to at least attempt to check if your query succeeds before using any result it may produce, you then also need to check if there are any records within that result before trying to display them. This way you can easily debug your logic.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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