HELP! display output using a href code

Discussion in 'PHP' started by buknoii, Oct 26, 2007.

  1. #1
    hi there! im a newbie and i have problems generating output using the code below

    view.php
    
    $result = mysql_query("select * from property_listings order by property_num desc") or 
    		die (mysql_error());
    		
    		while ($row = mysql_fetch_array($result))
    		
    			{
    				echo "<a href=view_post.php?xval=";
    				echo $row["property_num"];
    				echo ">";
    				echo $row["property_heading"];
    				echo "</a>";
    				echo "<br><br>";
    				
    			}
    					
    		mysql_free_result($result);
    
    PHP:




    view_post.php

    
    $result = mysql_query("select * from property_listings where property_num='".mysql_real_escape_string($_GET['xval'])."'") or 
    				die (mysql_error()); 
    				
    				while ($row = mysql_fetch_array($result))
    				
    				{
    					echo $row["property_heading"];
    				
    				}
    				
    				mysql_free_result($result);
    
    PHP:
    what i want, is that once a link is clicked on view.php it will go to view_post.php and will display the data generated by the sql query.

    my problem is that everytime i run view.php and i clicked a specific link on it, and once it opens view_post.php it doesnt display anything.

    property_num is a mediumint and im really not sure if the codes i entered in view_post.php are correct.


    PLEaSE HELp!
     
    buknoii, Oct 26, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    The value you're passing in view.php comes from the property_num field, but in view_post.php you're trying to fetch a row where this value equals property_heading. Maybe that's the issue?
     
    nico_swd, Oct 26, 2007 IP
  3. buknoii

    buknoii Guest

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i already changed it, but still no output..
     
    buknoii, Oct 26, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Try this.
    
    $result = mysql_query("
    	SELECT *
    	FROM
    		property_listings
    	ORDER BY
    		property_num desc
    ") or die (mysql_error());
            
    while ($row = mysql_fetch_array($result))
    {
    	echo '<a href="view_post.php?xval=' . $row["property_num"] . '">' . $row["property_heading"] . "</a><br /><br />\n";
    }
    
    mysql_free_result($result);
    
    PHP:
    
    $result = mysql_query("
    	SELECT *
    	FROM
    		property_listings
    	WHERE
    		property_num = '" . mysql_real_escape_string($_GET['xval']) . "'
    	LIMIT 1
    ") or die (mysql_error());
    
    $property = mysql_fetch_assoc($result);
    mysql_free_result($result);
    
    echo $property["property_heading"];
    
    
    PHP:
     
    nico_swd, Oct 26, 2007 IP
  5. buknoii

    buknoii Guest

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    great! thanks again nico
     
    buknoii, Oct 26, 2007 IP