How to convert PHP to C++ coding?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
project168
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 1:33 pm

How to convert PHP to C++ coding?

Post by project168 »

Is there a program which provides this compiling method?
Last edited by project168 on Sun Apr 03, 2011 10:29 am, edited 1 time in total.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

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

Post 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'];
 }
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
project168
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 1:33 pm

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

Post by project168 »

my primary key is CUST_NO
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

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

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply