...

View Full Version : Trying to use variable in row resource identifier



chornbeck
10-20-2011, 12:33 AM
Here's the code - you can probably see what I'm attempting... I want to populate the form fields with the data that matches that field from the client table. I can't seem to get the $fieldfill = $rowclient['".$field."']"; statement to work out... Any suggestions?


$resultclient = mysql_query("SELECT * FROM Clients WHERE ClientID = '$GetClientID' ") or die(mysql_error());

$rowclient = mysql_fetch_array( $resultclient );

$result = mysql_query("SHOW COLUMNS FROM Clients");

echo "<form action='edit_process.php'>";

while ($row = mysql_fetch_assoc($result)) {

$field = $row['Field'];

$fieldfill = $rowclient['".$field."']";

echo $field.": <input type='text' name='".$field."' value='".$fieldfill."' /><br /><br />";


}


echo "</form>"

sunfighter
10-20-2011, 05:46 PM
Try this:


$field = $row['Field'];
$fieldfill = $rowclient["$field"];
echo $field.": <input type='text' name=\"$field\" value=\"$fieldfill\" /><br /><br />";

Pay attention to the quotes.

Old Pedant
10-20-2011, 11:44 PM
HUH???

NO.



$field = $row['Field'];
$fieldfill = $rowclient[$field]; // NO QUOTES AT ALL
echo $field.": <input type='text' name=\"$field\" value=\"$fieldfill\" /><br /><br />";

sunfighter
10-21-2011, 03:37 PM
Pay attention to the quotes.

Guess I should.:(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum