Page 3 of 3

Re: Help with SQL query/PHP loop

Posted: Tue Dec 23, 2008 3:53 pm
by RobertGonzalez
No, what I am saying is echo out the row data however you want to see it and only use the "fulfilled" column value to show that the row you are on in the loop is fulfilled.

The way you are doing it in your code is still only showing the rows with the fulfilled flag set to "1". Don't put the display of the row data in the conditional, use a conditional to show whether the row is fulfilled or not.

Re: Help with SQL query/PHP loop

Posted: Tue Dec 23, 2008 4:06 pm
by TheBrandon
Everah wrote:Don't put the display of the row data in the conditional, use a conditional to show whether the row is fulfilled or not.
I'm sorry, I don't understand the difference.

I'm not asking you to do it for me, but can you explain a little more?

I think you're saying, right now, I have like, "if fulfilled, display" when I should have "display if fulfilled?"

Re: Help with SQL query/PHP loop

Posted: Tue Dec 23, 2008 4:12 pm
by RobertGonzalez
Nope, what I am saying is just display. Take out the "fulfilled" check altogether and see what comes out. Make sure to make your query order by the fulfilled date. Once you see all the data on the screen you will see what I am talking about when I say use the conditional to make a small notification in the list as to what is fulfilled.

Re: Help with SQL query/PHP loop

Posted: Tue Dec 23, 2008 4:39 pm
by TheBrandon
Everah wrote:Nope, what I am saying is just display. Take out the "fulfilled" check altogether and see what comes out. Make sure to make your query order by the fulfilled date. Once you see all the data on the screen you will see what I am talking about when I say use the conditional to make a small notification in the list as to what is fulfilled.
Yeah, I think I can get it by doing this:

for (client names) {
echo client name
for (reqeusts) {
echo user
echo status
if (fulfilled=0){ priority=100}
echo priority
}

Something like that. That would put the priority of the ones set to be hidden well at the bottom.

Now, 2 more random questions if you don't mind:

- How would I go about hiding clients entirely that have no requests? Right now we echo the client names before we check for the fulfilled status, so that would need to be re-done, right? This is just theoretical, and my desire to learn.

- Right now, even if I set my query to sort by priority only, they still mix inside the client. Meaning I could have:
--High Priority - Bob - Client 1
--High Priority - Bob - Client 2
--High Priority - Bob - Client 3
--Low Priority - Bob - Client 3
--High Priority - Bob - Client 3
--High Priority - Bob - Client 4

How could I keep them grouped, inside the client list? I can post a screenshot if you need to see what I mean. It sorts the entire list by priority, but then once we start grouping them (assigning the requests to the proper client) the sorting seems to stop.

This also is just theory. I'm just curious. Right now it works and I could go live with it. I'm just trying to understand ways to make it "better" if I wanted to.

Thank you again for all of your help. This forum never lets me down.

Re: Help with SQL query/PHP loop

Posted: Tue Dec 23, 2008 5:23 pm
by RobertGonzalez
The best way to get your clients list (if you only want clients that have requests) is to do a select statement on the clients that joins the requests table. Then you will only have clients with a request found in the requests table.

As for the sorts... if the data is coming out of the database sorted then the looping construct is not going to do anything to the sort order. If the sort order is changing something else is making it go wonky somewhere.

Re: Help with SQL query/PHP loop

Posted: Fri Feb 20, 2009 4:09 am
by fedrik
Its problematic if the data storage goes beyond the limit.