|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[1998-09-13 15:15 UTC] analyzer at kemuri dot net
Hi,
When I'm asking the fieldnames of a Mysql table, the lists stops
when a decimal-fields has been reached.
This is the output:
productid 20
name 255
sourceurl 255
price 8
This is the table definition:
productid varchar(20) not null,
name varchar(255) not null,
sourceurl varchar(255),
price decimal(8,2),
vat varchar(3),
weight decimal(5,2),
category mediumint,
min2order tinyint,
options text,
I guess the comma is wrong in Decimal..
Here's is a piece of code for version 3.0.3..
Kind Regards,
Geert
<?
$MY = mysql_pconnect("localhost","analyzer","AnA56g!");
mysql_select_db("linuxcorner",$MY);
function ProductForm($productid) {
global $MY;
$res = mysql_query("select * from products",$MY);
$fieldsnr = mysql_list_fields("linuxcorner", "products");
echo '<TABLE BORDER="0">';
for($i=0; $i <= $fieldsnr; $i++) {
$fname = mysql_field_name($res,$i);
$flength = mysql_field_len($res, $i);
echo "<TR><TD>$fname $flength</TD>\n";
"</TR>";
}
echo '</TABLE>';
}
ProductForm("blah");
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 01:00:02 2025 UTC |
This script makes no sense. I've fixed it up and it works exactly as expected: <? $MY = mysql_connect(...); mysql_select_db("foo",$MY); function ProductForm($productid) { global $MY; $res = mysql_list_fields("foo", "bar") or die(mysql_error()); $fieldsnr = mysql_num_fields($res); echo '<TABLE BORDER="0">'; for($i=0; $i < $fieldsnr; $i++) { $fname = mysql_field_name($res,$i); $flength = mysql_field_len($res, $i); echo "<TR><TD>$fname $flength</TD>\n"; "</TR>"; } echo '</TABLE>'; } ProductForm("blah"); ?>