How to use PHP to read/fetch the database's first attribute/entry?

I want my PHP coding to read/fetch my database’s first attribute/entry like the first number of the client in that first row and then fetch it to be shown on PHP so that it will show ‘1’. How would I do that?

Here’s the table of my example database (MySQL)

I know the command to select the line via the database is this:

SELECT * FROM CUSTOMER WHERE CUST_NO=1;

Oh and my primary key is CUST_NO

Hi, I’m very new at this but I got it to work with this

[php]$fld = “ID”;
$q = “SELECT * FROM CUSTOMER ORDER BY CUST_NO”;
$rst = mysql_query($q);
$row = mysql_fetch_object($rst);
echo $row->$fld;[/php]

I hope it works!

…pasted it wrong…

[php]$fld = “CUST_NO”;
$q = “SELECT * FROM CUSTOMER ORDER BY CUST_NO”;
$rst = mysql_query($q);
$row = mysql_fetch_object($rst);
echo $row->$fld;

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service