| | |
help needed
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 2
Reputation:
Solved Threads: 0
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
PHP Syntax (Toggle Plain Text)
mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ $row_Recordset2 = $row ['Name']
•
•
Join Date: May 2008
Posts: 232
Reputation:
Solved Threads: 19
php Syntax (Toggle Plain Text)
mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ //If you want to echo a field called Name print($row['name']); //A field called Age print($row['age']); //Website print($row['website']); }
php Syntax (Toggle Plain Text)
print($row['MySQL_Field_Name']);
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 =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: May 2008
Posts: 232
Reputation:
Solved Threads: 19
php Syntax (Toggle Plain Text)
mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ //If you want to echo a field called Name print($row['name']); //A field called Age print($row['age']); //Website print($row['website']); }
php Syntax (Toggle Plain Text)
print($row['MySQL_Field_Name']);
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 =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: May 2008
Posts: 232
Reputation:
Solved Threads: 19
php Syntax (Toggle Plain Text)
mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ //If you want to echo a field called Name print($row['name']); //A field called Age print($row['age']); //Website print($row['website']); }
php Syntax (Toggle Plain Text)
print($row['MySQL_Field_Name']);
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 =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: Jun 2009
Posts: 2
Reputation:
Solved Threads: 0
Hi thank you,the code is suppose to select each row of a table name profile.
PHP Syntax (Toggle Plain Text)
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $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", GetSQLValueString($_POST['Address'], "text"), GetSQLValueString($_POST['Tracking_Number'], "text"), GetSQLValueString($_POST['Phone_Number'], "text"), GetSQLValueString($_POST['Delivery_Address'], "text"), GetSQLValueString($_POST['Country'], "text"), GetSQLValueString($_POST['Contact_Person'], "text"), GetSQLValueString($_POST['Phone'], "text"), GetSQLValueString($_POST['Transit_Status'], "text"), GetSQLValueString($_POST['Route_No'], "text"), GetSQLValueString($_POST['Time'], "date"), GetSQLValueString($_POST['Date'], "date"), GetSQLValueString($_POST['Name'], "text")); mysql_select_db($database_profiles, $profiles); $Result1 = mysql_query($updateSQL, $profiles) or die(mysql_error()); $updateGoTo = "10.gif"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ $row_Recordset2 = $row ['Name'] ['Address']; } $totalRows_Recordset2 = mysql_num_rows($Recordset2); form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Name:</td> <td><?php echo $row_Recordset2['Name']; ?></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Address:</td> <td><input type="text" name="Address" value="<?php echo htmlentities($row_Recordset2['Address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Tracking Number:</td> <td><input type="text" name="Tracking_Number" value="<?php echo htmlentities($row_Recordset2['Tracking Number'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Phone Number:</td> <td><input type="text" name="Phone_Number" value="<?php echo htmlentities($row_Recordset2['Phone Number'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Delivery Address:</td> <td><input type="text" name="Delivery_Address" value="<?php echo htmlentities($row_Recordset2['Delivery Address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr>
Last edited by whizzykid; Jun 4th, 2009 at 6:44 am.
•
•
•
•
try to use mysql_fetch_array method not mysql_fetch_assoc method
i think that will be print the other columns from your database
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
![]() |
Similar Threads
- Harddrive failure and 100% CPU under Win2K, Help Needed! (Windows NT / 2000 / XP)
- XP PRO iis help needed (Windows NT / 2000 / XP)
- CWS. help needed (Viruses, Spyware and other Nasties)
- are all these needed (Windows NT / 2000 / XP)
- help much needed !! (OS X)
Other Threads in the PHP Forum
- Previous Thread: Porblem in UTF-8 support on CSV/EXCEL
- Next Thread: Warning: mysql_fetch_assoc(): 2 is not a valid MySQL result resource
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube






