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

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']

Recommended Answers

All 6 Replies

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']);
}

So find the name of the field you want to output and put that into the $row array value

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!

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']);
}

So find the name of the field you want to output and put that into the $row array value

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!

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']);
}

So find the name of the field you want to output and put that into the $row array value

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!

Hi thank you,the code is suppose to select each row of a table name profile.

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>

try to use mysql_fetch_array method not mysql_fetch_assoc method
i think that will be print the other columns from your database

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.

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.