Page 1 of 1

How to convert PHP to C++ coding?

Posted: Sun Mar 27, 2011 12:59 pm
by project168
Is there a program which provides this compiling method?

Re: How to use PHP to read/fetch the database's first attrib

Posted: Sun Mar 27, 2011 4:58 pm
by social_experiment
Unless CUST_NO is an auto-incrementing field your query may not select the first record. What is your primary key for this table?

Code: Select all

<?php
 // selects the record with the lowest primary key value
 $query = "SELECT * FROM customer ORDER BY pk_field ASC LIMIT 1";
 // to display it
 $sql = mysql_query($query);
 while ($ary = mysql_fetch_array($sql)) {
  echo $ary['CUST_NO'];
  echo $ary['CUST_FNAME'];
  echo $ary['CUST_LNAME'];
  echo $ary['CUST_PHONE'];
 }
?>

Re: How to use PHP to read/fetch the database's first attrib

Posted: Mon Mar 28, 2011 7:01 pm
by project168
my primary key is CUST_NO

Re: How to use PHP to read/fetch the database's first attrib

Posted: Tue Mar 29, 2011 9:47 am
by social_experiment
So there shouldn't be any problems. Order by primary key ASC and limit by 1, that will give you the first row in the table.