Forum Moderators: coopster
<?php
$userid = $_SESSION['userid'];
$sql = "SELECT firstname, lastname FROM table WHERE userid = {$userid}";
execute query, fetch row into variables
?>
<form>
First Name: <input name="firstname" value="<?php print $firstname; ?>">
Last Name: <input name="lastname" value="<?php print $lastname; ?>">
<input name="formSubmit" type="submit" value="Submit Changes">
</form>
i mean is there any way fetch the value from the database with out specific field ..
function field_names($tablename) {
if (! isset($table)) { die("No table name in field names"); }
$fields = Array();
$counter=0;
$result = mysql_query("show columns from $table") or die ("Could not get table names");
while ($row = mysql_fetch_array($result)) {
$fields[$counter]=$row[0];
$counter++;
}
return $fields;
}
if (is_numeric($the_id) and ($the_id > 0)) {
$myvalues = get_record($tablename,$fields,$identifier,$id);
}
//
function get_record($table,$tablefields,$field,$target_id) {
//
$allvalues=array();
$select = "select * from $tablename where $field=$target_id";
$result=mysql_query("$select") or die("Could not get record for table $table");
//
if ($row=mysql_fetch_array($result)) {
foreach ($tablefields as $fld) { $allvalues[$fld] = $row[$fld]; }
}
return $allvalues;
}
foreach ($fields as $fld) {
if (! in_array($fld,$ignoreme)) {
echo "<p><label for=\"$fld\">" . $english[$fld] . ":</label>
<input type=\"text\" name=\"$fld\" id=\"$fld\" value=\"" . $myvalues[$fld] . "\"></p>\n";
}
}