note 35123 deleted from function.mysql-field-name by didou
| From: | didou@php.net | Date: | Wed, 20 Aug 2003 14:39:27 +0000 |
| Subject: | note 35123 deleted from function.mysql-field-name by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54766@lists.php.net to get a copy of this message | ||
Note Submitter: "Hassan Nasseri"<irnavash@yahoo.com>
----
<?php
/* show_record() generates a form for updating any mysql tables
record .. asigning filed's value to its name with setting maxlenght ..
submitted form returns filed values in $record list & u can update
$table with the same method.
*/
function show_record($table,$id){
$query = "select * from ".$table." where
id='".$id."'";
if(!$result = mysql_query ($query)) return NULL;
$row = mysql_fetch_array($result);
echo "<form method=\"post\"
action=\"".$PHP_SELF."\">";
echo "<input type=\"hidden\" name=\"table\"
value=\"".$table."\">";
echo "<input type=\"hidden\" name=\"id\"
value=\"".$id."\">";
echo "<table border=\"0\">";
echo "<tr><td>Redord :
".$key."</td></tr><tr><td> </td></tr>";
$i = 0;
while ($i < mysql_num_fields($result)) {
$field_name = mysql_field_name($result,$i);
echo "<tr><td>".$field_name." :
</td><td><input type=\"text\"
name=\"record[".$field_name."]\" size=\"40\"
maxlength=\"".mysql_field_len($result,$i)."\"
value=\"".$row[$field_name]."\" ></td></tr>";
$i++;
}
echo
"<tr><td> </td></tr><tr><td></td><td>
<input type=\"submit\" name=\"update\" value=\"Update\"
></td></tr>";
echo "</table>";
echo "</form>";
return 1;
} // End show_record()
?>