A: 

A while loop doesn't create a new scope, as you can see here: http://codepad.org/H1U3wXZD
About the code itself, here's a few suggestions:

0) I would consider having a database abstraction layer (PDO would be good enough).

1) Learn how to use JOIN's. It looks like you could fetch all the necessary information with a single query, something like:

    SELECT p.id, p.proj, c.id, c.fname, c.title 
      FROM proj p 
INNER JOIN pic c ON c.projid=p.id 
     WHERE catid='<your category>' 
  ORDER BY p.ordr, c.ordr

2) You should separate the code that gets data from the db from the code that constructs the HTML (?). Perhaps you could put that in another method. Something like:

if ($cmd == 'catSelect') {
    $data = getData($params['category']);

    foreach ($data as $value) {
        // process data here
    }
}

3) I take it you are using the generated JSON to send it via AJAX to a client. In that case, I would totally cut the fat (eg: generated markup) and send only essentials (picture id, title, fname and whatever else is essential) and generate the code on the client side. This will make your page load faster and save you and your visitors bandwidth.

NullUserException
it is intentional for the $i to be reset to 0 every time to generate thumbnail when returning to outer loop. Thanks for pointing out my assignment error though at the top :S I should move it to the if scope though.
Adgezaza
@Adgezaza I see, the indentation tricked me. This is still very ugly code IMO. Let me update my answer.
NullUserException
I know there shouldn't be a scope issue with a while loop which is why I am stuck. Is there any other reason why this could happen? Anything in MySql that could break the code? But I am not getting any fail select warnings like I was earlier.
Adgezaza
oh just saw your latest response. I will try that out.
Adgezaza
took your advise but same problem, here is the response I get. {"status":"ok","projects":[],"files":[],"titles":[]} I've tested the statement in the back end and it seems to work fine. Posted new code.
Adgezaza
A: 

my jquery/ajax client side script was not sending in category properly and therefore was no selecting any rows.

The above code will work.

Adgezaza
A: 

Within the loop try something like this :

while($row = mysql_fetch_assoc($proj_result)){  
    $projects[]=$row["pid"];
    $files[]=$row["name"];
    $titles[]=$row["title"];

    echo $row["pid"]." -- ".$row["name"]." -- ".$row["title"]."\n";
}

Do you get anything? Once you have tried it we will take it from there. My guess is that you aren't getting any data from MySQL.

Sabeen Malik
A: 

Hey

I got the same problem:

 if(mysql_num_rows($result)>0){
     while($row = @ mysql_fetch_array($result,MYSQL_BOTH)){
        $arr[$i][0] = $row["domain"];
        $arr[$i][1] = $row["keyword"];
        $arr[$i][2] = $row["isActivate"];
        echo $arr[0][1];
        $i++;


     }

 }
 echo $arr[0][1];

The first echo will print out the result, but the second won't

Wei