I have the following code which should work as follows.
I have a table called "access" which holds login details for every user. Each user is assigned to a customer reference, therefore there can be several lines in the table that have the same customer reference as they are different users who access the same account.
I need to be able to produce a list of active accounts based upon the first two letters of the customer reference. The purpose of this is to allow the individuals who sell the accounts to see how their customers are performing.
Each account is based upon 2 letters followed by 4 numbers, ie:
xx8888
The script works so far as it tels me how many unique rows there are but it prints out the same reference each time.
$channelref = substr($custref, 0, 2);
echo "Channel ref - ",$channelref,"<br>";
$sql = "Select DISTINCT access.custref from access where custref like '%$channelref%' group by custref";
// run SQL against the DB
$result = mysql_query($sql)
or die("Search failed");
$number = MYSQL_NUMROWS($result);
echo "Number of rows - ",$number,"<br>";
for($i=0;$i<$number;$i++) {
echo "References are - ",$myrow['custref'],"<br>";
}
For example the table has 5 entries:
tr0000
tr0000
tr0000
tr0001
tr0002
However the results printed show
tr0000
tr0000
tr0000
Any help greatly appreciated.