help needed

Reply

Join Date: Jun 2009
Posts: 2
Reputation: whizzykid is an unknown quantity at this point 
Solved Threads: 0
whizzykid whizzykid is offline Offline
Newbie Poster

help needed

 
0
  #1
Jun 4th, 2009
i have this code,but it only displays the name but doesnt display other rows frm my database.i am very new to loop and arrays. thanks
  1. mysql_select_db($database_profiles, $profiles);
  2.  
  3. $query_Recordset2 = "SELECT * FROM biodata";
  4. $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error());
  5. while ($row = mysql_fetch_assoc($Recordset2)){
  6. $row_Recordset2 = $row ['Name']
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 232
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 19
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: help needed

 
0
  #2
Jun 4th, 2009
  1. mysql_select_db($database_profiles, $profiles);
  2.  
  3. $query_Recordset2 = "SELECT * FROM biodata";
  4. $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error());
  5. while ($row = mysql_fetch_assoc($Recordset2)){
  6. //If you want to echo a field called Name
  7. print($row['name']);
  8. //A field called Age
  9. print($row['age']);
  10. //Website
  11. print($row['website']);
  12. }
So find the name of the field you want to output and put that into the $row array value
  1. print($row['MySQL_Field_Name']);
Enjoy
P.S. Please post complete code (Your while loop was not complete) also if it had been a connection problem we wouldn't have known because your Connect statement is not shown!
Last edited by samarudge; Jun 4th, 2009 at 6:26 am. Reason: Error In Code
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 232
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 19
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: help needed

 
0
  #3
Jun 4th, 2009
  1. mysql_select_db($database_profiles, $profiles);
  2.  
  3. $query_Recordset2 = "SELECT * FROM biodata";
  4. $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error());
  5. while ($row = mysql_fetch_assoc($Recordset2)){
  6. //If you want to echo a field called Name
  7. print($row['name']);
  8. //A field called Age
  9. print($row['age']);
  10. //Website
  11. print($row['website']);
  12. }
So find the name of the field you want to output and put that into the $row array value
  1. print($row['MySQL_Field_Name']);
Enjoy

P.S. Please post complete code (Your while loop was not complete) also if it had been a connection problem we wouldn't have known because your Connect statement is not shown!
Last edited by samarudge; Jun 4th, 2009 at 6:27 am. Reason: Error In Post
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 232
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 19
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: help needed

 
0
  #4
Jun 4th, 2009
  1. mysql_select_db($database_profiles, $profiles);
  2.  
  3. $query_Recordset2 = "SELECT * FROM biodata";
  4. $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error());
  5. while ($row = mysql_fetch_assoc($Recordset2)){
  6. //If you want to echo a field called Name
  7. print($row['name']);
  8. //A field called Age
  9. print($row['age']);
  10. //Website
  11. print($row['website']);
  12. }
So find the name of the field you want to output and put that into the $row array value
  1. print($row['MySQL_Field_Name']);
Enjoy

P.S. Please post complete code (Your while loop was not complete) also if it had been a connection problem we wouldn't have known because your Connect statement is not shown!
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 2
Reputation: whizzykid is an unknown quantity at this point 
Solved Threads: 0
whizzykid whizzykid is offline Offline
Newbie Poster

Re: help needed

 
0
  #5
Jun 4th, 2009
Hi thank you,the code is suppose to select each row of a table name profile.
  1. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  2. $updateSQL = sprintf("UPDATE biodata SET Address=%s, `Tracking Number`=%s, `Phone Number`=%s, `Delivery Address`=%s, Country=%s, `Contact Person`=%s, Phone=%s, `Transit Status`=%s, `Route No`=%s, `Time`=%s, `Date`=%s WHERE Name=%s",
  3. GetSQLValueString($_POST['Address'], "text"),
  4. GetSQLValueString($_POST['Tracking_Number'], "text"),
  5. GetSQLValueString($_POST['Phone_Number'], "text"),
  6. GetSQLValueString($_POST['Delivery_Address'], "text"),
  7. GetSQLValueString($_POST['Country'], "text"),
  8. GetSQLValueString($_POST['Contact_Person'], "text"),
  9. GetSQLValueString($_POST['Phone'], "text"),
  10. GetSQLValueString($_POST['Transit_Status'], "text"),
  11. GetSQLValueString($_POST['Route_No'], "text"),
  12. GetSQLValueString($_POST['Time'], "date"),
  13. GetSQLValueString($_POST['Date'], "date"),
  14. GetSQLValueString($_POST['Name'], "text"));
  15.  
  16. mysql_select_db($database_profiles, $profiles);
  17. $Result1 = mysql_query($updateSQL, $profiles) or die(mysql_error());
  18.  
  19. $updateGoTo = "10.gif";
  20. if (isset($_SERVER['QUERY_STRING'])) {
  21. $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  22. $updateGoTo .= $_SERVER['QUERY_STRING'];
  23. }
  24. header(sprintf("Location: %s", $updateGoTo));
  25. }
  26.  
  27. mysql_select_db($database_profiles, $profiles);
  28.  
  29. $query_Recordset2 = "SELECT * FROM biodata";
  30. $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error());
  31. while ($row = mysql_fetch_assoc($Recordset2)){
  32. $row_Recordset2 = $row ['Name'] ['Address'];
  33.  
  34.  
  35. }
  36.  
  37. $totalRows_Recordset2 = mysql_num_rows($Recordset2);
  38. form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  39. <table align="center">
  40. <tr valign="baseline">
  41. <td nowrap="nowrap" align="right">Name:</td>
  42. <td><?php echo $row_Recordset2['Name']; ?></td>
  43. </tr>
  44. <tr valign="baseline">
  45. <td nowrap="nowrap" align="right">Address:</td>
  46. <td><input type="text" name="Address" value="<?php echo htmlentities($row_Recordset2['Address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  47. </tr>
  48. <tr valign="baseline">
  49. <td nowrap="nowrap" align="right">Tracking Number:</td>
  50. <td><input type="text" name="Tracking_Number" value="<?php echo htmlentities($row_Recordset2['Tracking Number'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  51. </tr>
  52. <tr valign="baseline">
  53. <td nowrap="nowrap" align="right">Phone Number:</td>
  54. <td><input type="text" name="Phone_Number" value="<?php echo htmlentities($row_Recordset2['Phone Number'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  55. </tr>
  56. <tr valign="baseline">
  57. <td nowrap="nowrap" align="right">Delivery Address:</td>
  58. <td><input type="text" name="Delivery_Address" value="<?php echo htmlentities($row_Recordset2['Delivery Address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  59. </tr>
Last edited by whizzykid; Jun 4th, 2009 at 6:44 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 1
Reputation: Musab405 is an unknown quantity at this point 
Solved Threads: 0
Musab405 Musab405 is offline Offline
Newbie Poster

sol

 
0
  #6
Jun 4th, 2009
try to use mysql_fetch_array method not mysql_fetch_assoc method
i think that will be print the other columns from your database
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 465
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: sol

 
0
  #7
Jun 4th, 2009
Originally Posted by Musab405 View Post
try to use mysql_fetch_array method not mysql_fetch_assoc method
i think that will be print the other columns from your database
No, not at all dear.

mysql_fetch_array() returns indexed array so you can get value of specific column using index 0,1, and so on.

mysql_fetch_assoc() method returns an array having key-value pair. Keys are columns of table and you may arbitrary access the column value by their column name.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC