html - PHP - Display mysql single record php via id from database -


my html lists rows database table (venues), want view records separately. user should able click row, , redirected single page , see details.

here 1st page.

<?php  // include connection file. include("func.inc.php");  //////displaying data/////////////   $venue_id = mysql_real_escape_string($_get['venue_id']);  $venue_id=$_get['venue_id'];  $city=$_get['city']; $reason=$_get['reason']; $budget=$_get['budget'];  // select rows in markers table $query = sprintf(    "select city, reason, budget, venue_name, description, venue_id venues city = '%s' , reason = '%s' , budget = '%s' ",    mysql_real_escape_string($city),    mysql_real_escape_string($reason),    mysql_real_escape_string($budget) );  $result = mysql_query($query);  if($result == false) {    die(mysql_error() . "<br />\n$query"); } if(mysql_num_rows($result) == 0) {    user_error("no rows returned by:<br />\n$query"); }  ?>  <?php   while($row = mysql_fetch_array($result)) { ?>   <tr>     <td> <a href="venue.php?venue_id=<?php echo $row['venue_id']; ?>"><?php echo $row['venue_name']; ?></a></td>     <td><?php echo $row['image']; ?></td>     <td><?php echo $row['description']; ?></td> </tr>  <?php }   ?> 

here 2nd page, venue.php:

<?php  // include connection file. include("func.inc.php");  $venue_id = mysql_real_escape_string($_get['venue_id']); $venue_id = $_get['venue_id'];  // select rows in markers table $query = sprintf('select * venues venue_id = "'.$venue_id.'" ', mysql_real_escape_string($venue_id));   $result = mysql_query($query); $result = mysql_fetch_assoc($result);   if($result == false) {    die(mysql_error() . "<br />\n$query"); } if(mysql_num_rows($result) == 0) {    user_error("no rows returned by:<br />\n$query"); }  ?> 

i'm close, $venue_id isn't carrying on next page , single details aren't populating. how fix this? thanks!

there issue in code firstly. why do :

$venue_id = mysql_real_escape_string($_get['venue_id']); $venue_id=$_get['venue_id']; 

really thats not efficient. can example :

$venue_id = (int) $_get['venue_id']; 

that way cast value integer (i think value integer). , no need make mysql_real_escape_string (which useful text).

secondly main issue, see in first page, in html venue_id set in

<a href="venue.php?id=xxxx"> 

when clic on it, in url of landing page ? : www.example.com/venue.php?id=xxxx

did try echo $_get["venue_id"] ? problem in url set 'id' , in landing page search 'venue_id'

put <a href="venue.php?**venue_id**=xxxx">


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -