note 35123 added to function.mysql-field-name
| From: | \ " Hassan Nasseri \ | Date: | Wed, 20 Aug 2003 14:11:06 +0000 |
| Subject: | note 35123 added to function.mysql-field-name | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54763@lists.php.net to get a copy of this message | ||
<?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()
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-field-name.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35123
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35123&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35123&report=yes