I'm not sure if I understood you correctly, but from what I understand, once
I select a project category like "Pre-Approved", I need to be able to
iterate through all the records that match that condition.
So why not just have a single variable $result for all conditions. Since
only one condition is ever going to be true, and if you are gonna exit the
switch() after fetching the value from the database, you may just use
$result for all conditions.
If that is not what you meant, why not use an array such as
$result = mysql_query($sql);
$result = mysql_query($sql2);
and so on.... and store an index to the query you wanted...
Natividad Castro writes:
> Hi to all,
> I have a search form where users can search project by 'Project Name' after
> they type in the project name, they will select which project they will like
> to view from a drop down menu which contains: Management Approve,
> Pre-Approved, Management-Not-Approved, and Pre-Not-Approved pproved.
> I'm using switch statement
> switch ($project)
> case "Management Approve"
> $sql = mysql_query("select * from project where project_name='$pro_name'
> and final_approved='yes'");
> $result = mysql_query($sql);
> $record_count = mysql_num_rows($result);
> case "Pre-Approved":
> $sql2 = mysql_query("select * from project where project_name='$pro_name'
> and first_approved='yes'");
> $result2 = mysql_query($sql2);
> $record_count2 = mysql_num_rows($result2);
> and so on...
> My question is: how do I call $sql, or $sql2, and $result, or $result2 to
> loop and put the fields into an array? The reason I'm asking is because the
> users will be able to navegate through the recordset, so I need to call just
> the query that match the criteria either '$result' or '$result2' to be able
> to display the right information.
> while($query_data = mysql_fetch_array($result)) //it can be $result2
> $project_id = $query_data[project_id];
> $project_name = $query_data[project_name];
> I'm not sure if this explanation make sence to you guys, but if anybody
> would like to take the time and try to help me out, that would be great
> Thanks in advanced
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php