This is a discussion on "[SOLVED] PHP variable handling problems" within the PHP Forum section. This forum, and the thread "[SOLVED] PHP variable handling problems are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] PHP variable handling problems
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Basically my database is setup like this:
sections -> id,sid,name menu -> item,sid the menu sid corresponds with the section id The code below is supposed to pull the section id from the sections table and then for every section, it is supposed to pull the menu item that belongs in that section. Section1 has 3 items item1 from section1 item2 from section1 item3 from section1 Section2 has 1 item item1 from section2 item2 from section2 Section3 has 4 items item1 from section3 item2 from section3 item3 from section3 item4 from section3 The first loop works fine, it picks up the correct section ids. The second loop to pick up the actual items in the section fails. It acts like it is looping through(ie. every section gets the # of items it actually has) But the data is from the 1st section only. ie, the 2nd and 3rd and 4th sections all contain the data from the 1st section. It actually looks like this: (please note the section# from which it is pulling the item....different from above) Section1 has 3 items item1 from section1 item2 from section1 item3 from section1 Section2 has 1 item item1 from section1 item2 from section1 Section3 has 4 items item1 from section1 item2 from section1 item3 from section1
Last edited by Rakuli; Oct 15th, 2007 at 09:18. Reason: changed [code] to [php] tags for easier reading |
|
|
|
||||
|
Re: PHP variable handling problems
I think your problem is here:
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
|||
|
Re: PHP variable handling problems
No. Sorry I forgot to put that in the database section. rid is the restaurant id. I'm pulling the items from that restaurant only where the sid is the section id and ordering them id.
|
|
||||
|
Re: PHP variable handling problems
where does the main FOR loop end? There's a missing "}".
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: PHP variable handling problems
Hi there,
The loops don't appear to be necessary. I changed your code a bit, this way you can tell for sure if it;s the query that is wrong because the loops are inside of loops.
Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: PHP variable handling problems
Had to modify a few things to fit it in with the rest of the code, but it works great
I think I was just making it too complicated. Remember KISS Thanks a lot. Last edited by DerrickE; Oct 15th, 2007 at 22:12. |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Extracting filename without extension from variable string. | frankenscarf | JavaScript Forum | 3 | Jan 11th, 2008 16:54 |
| [SOLVED] Sending variable from one php file to another | eon201 | PHP Forum | 2 | Oct 31st, 2007 15:48 |
| [SOLVED] ASP Session Variable | Monie | Classic ASP | 7 | Oct 10th, 2007 02:44 |
| variable problems... | tehrobot | Flash & Multimedia Forum | 4 | Sep 13th, 2006 13:01 |
| [SOLVED] Passing my variable, help please | Anonymous User | PHP Forum | 0 | Feb 12th, 2005 13:37 |