Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Can't get lowest ID of SQL Group

Codes here !

Moderators: macek, egami, gesf

Can't get lowest ID of SQL Group

Postby karabey81 » Mon Jun 16, 2014 5:51 am

How can I display correctly the results of my MySQL Code in PHP? I have already wrote a PHP Code with while but somehow the result will not be correctly displayed.

SQL FIDDLE:!2/f06d6/1

In SQL Fiddle are the lowest ID with CPFAD shown.

I am trying to show the columns CNAME and CPFAD. CPFAD should be taken from the lowest NNR.

My PHP Code seems like here
Code: Select all
while ($row = mysql_fetch_assoc($result)){

    $cName= $row['cName'];
    $cPfad = $row['cPfad'];
    $nNr = $row['min_nNr'];

    echo $cName;
    echo $cPfad;

But somehow the result runs different than I want it. Instead to show from the lowest NNR the CPFAD on each loop, it display like below:

Code: Select all
TITLE 1 - picture4.jpg
TITLE 1 - picture3.jpg
TITLE 1 - picture2.jpg
TITLE 1 - picture1.jpg
TITLE 2 - picture5.jpg
TITLE 2 - picture4.jpg
TITLE 2 - picture3.jpg
TITLE 2 - picture2.jpg

Interesting but it should show only from the lowest NNR and the CPFAD of it like below.

Code: Select all
TITLE 1 - picture1.jpg
TITLE 2 - picture5.jpg

Is my PHP Code wrong?
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jun 16, 2014 5:47 am

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.