error in displaying results.

Thread Solved

Join Date: May 2008
Posts: 29
Reputation: heels is an unknown quantity at this point 
Solved Threads: 0
heels heels is offline Offline
Light Poster

error in displaying results.

 
0
  #1
Jun 6th, 2008
hi,

this is a snippet of my codes,

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

editFunction.php
  1. <?php
  2. //get variables from previous page
  3. $ID = $_GET['ID'];
  4.  
  5.  
  6. //sql statement to retrieve the commands
  7. $sql = "SELECT * FROM contacts WHERE ID LIKE '".$ID."'";
  8.  
  9. //execute query
  10. $result = mysql_query($sql) or die (mysql_error());
  11.  
  12. //display on table
  13. $contact = mysql_num_rows($result); {
  14. ?>
  15. .
  16. ......
  17. <td width="140"><span class="style2">ID : </span></td>
  18. <td width="384">
  19. <input name="ID" type="ID" id="ID" value="<? echo $_GET['ID'] ?>" size="50" readonly /> </td>
  20. </tr>
  21. <tr>
  22. <td width="140"><span class="style2">First Name : </span></td>
  23. <td width="384">
  24. <input name="firstName" type="text" id="firstName" value="<? echo $contact['firstName'] ?>" size="50" /> </td>
  25. </tr>
  26. </table>
  27.  
  28. <?php
  29.  
  30. }
  31. ?>
  32. </body>
  33. </html>
why aren't my results displaying out in the respective fields except for ID?
where do i start debugging? Thanks alot.
Last edited by peter_budo; Jun 10th, 2008 at 7:27 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: error in displaying results.

 
0
  #2
Jun 6th, 2008
because contact contains the number of rows returned by the query.

change:

  1. $contact = mysql_num_rows($result);

to

  1. $contact = mysql_fetch_assoc($result);
Last edited by kkeith29; Jun 6th, 2008 at 5:06 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 4
Reputation: gurmukh is an unknown quantity at this point 
Solved Threads: 1
gurmukh gurmukh is offline Offline
Newbie Poster

Re: error in displaying results.

 
0
  #3
Jun 6th, 2008
using this wll help you.
actually mysql_assoc is used to retrive resuts form
  1. while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  2. {
  3. echo "Name :{$row['name']} <br>" .
  4. "Subject : {$row['subject']} <br>" .
  5. "Message : {$row['message']} <br><br>";
  6. }
Last edited by peter_budo; Jun 10th, 2008 at 7:28 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: error in displaying results.

 
0
  #4
Jun 6th, 2008
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.
Last edited by kkeith29; Jun 6th, 2008 at 6:37 am.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 8
Reputation: sankar62 is an unknown quantity at this point 
Solved Threads: 1
sankar62 sankar62 is offline Offline
Newbie Poster

Re: error in displaying results.

 
0
  #5
Jun 6th, 2008
use mysql_fetch_array ..........
for mysql_num_rows........
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 29
Reputation: heels is an unknown quantity at this point 
Solved Threads: 0
heels heels is offline Offline
Light Poster

Re: error in displaying results.

 
0
  #6
Jun 9th, 2008
ah, thanks alot. PROBLEM SOLVED
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC