Need a little expert PHP help for a sub menu save after page reload

Panther28

Elite Member
Executive VIP
Jr. VIP
Joined
May 2, 2010
Messages
9,943
Reaction score
16,050
After a little help here, hope you can spare a moment to take a look @jamie3000,

Now, I have a primary menu that loads into the database via ajax.
That works perfectly after the page is reloaded. ie, the primary menu is populated again.

The code I used to achieve this is.

PHP:
<?php $x = ((empty($gigObject->getMaincat())) || ($gigObject->getMaincat() == '>Select a Category')) ? 'selected="selected"' : ''; echo $x; ?>

And I use that sort of formatting for the rest of the menu choices.

in the submenu's I have

PHP:
<?php $x = ((empty($gigObject->getSubcat())) || ($gigObject->getSubcat() == 'Audiobooks')) ? 'selected="selected"' : ''; echo $x; ?>

for example. The database updates when both the submenu & primary menu change. Both values are stored in the db, yet, I just can't seem to get the submenu to load the preset choice.

Any help from someone would be much appreciated.

Thanks very much, ya'll
 
I would suggest switching to a framework like Laravel, it will be like a fresh breathe on a very hot day. Such problems will disappear, there are some really good packages that offers handling exactly what you are now battling.

Anyhow, of course, its not always possible to switch, so to debug your problem - can you please do the following:

Check if,
- gigObject->getSubcat() really returns the subcategory you are requesting
- ajax is really requested and it returns something at all, you can do it by checking chrome dev console

In any case, more information should be shared to really help with the issue here.

edit: Thread subject suggest that the problem is with saving the state instead of loading it?
 
What do you get when you do var_dump(($gigObject->getSubcat());

Also if this is a fresh project then I would also recommend laravel. Although it looks like you're editing an existing CMS?
 
What do you get when you do var_dump(($gigObject->getSubcat());

Also if this is a fresh project then I would also recommend laravel. Although it looks like you're editing an existing CMS?
Fixed it, i did that var dump on both the primary & sub menu, and only the primary worked, but the submenu showed me "Sub Menu" text, which I searched for found, and made a little adjustment to call the sub menu object properly, which wasn't in a place where it should have been.

Thanks guys, appreciated.
 
Back
Top