hi,

this is a snippet of my codes,

<td><a href="editFunction.php?ID=<?php echo $contact; ?>">update</a></td>
after clicking "update", the ID will be passed to the editFunction.php page.

editFunction.php

<?php 
		//get variables from previous page
		$ID = $_GET['ID'];
		
		
		//sql statement to retrieve the commands 
		$sql = "SELECT * FROM contacts WHERE ID LIKE '".$ID."'";
		
		//execute query 
		$result = mysql_query($sql) or die (mysql_error());
		
		//display on table 
		$contact = mysql_num_rows($result);  {
?> 
.
......
<td width="140"><span class="style2">ID : </span></td>
    <td width="384">
	  <input name="ID" type="ID" id="ID" value="<? echo $_GET['ID'] ?>" size="50" readonly />        </td>
  </tr>
  <tr>
    <td width="140"><span class="style2">First Name : </span></td>
    <td width="384">
      <input name="firstName" type="text" id="firstName" value="<? echo $contact['firstName'] ?>" size="50" />        </td>
  </tr>
</table>

<?php 
			
            }
?>
</body>
</html>

why aren't my results displaying out in the respective fields except for ID?
where do i start debugging? Thanks alot.

because contact contains the number of rows returned by the query.

change:

$contact = mysql_num_rows($result);

to

$contact = mysql_fetch_assoc($result);

using this wll help you.
actually mysql_assoc is used to retrive resuts form

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo "Name :{$row['name']} <br>" .
         "Subject : {$row['subject']} <br>" . 
         "Message : {$row['message']} <br><br>";
}

i don't think he needs the while loop because he is updating a specific row.

i use mysql_fetch_assoc() all the time. works perfectly. you can also use mysql_fetch_array, they complish the same thing.

use mysql_fetch_array ..........
for mysql_num_rows........

ah, thanks alot. PROBLEM SOLVED :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.