PDA

View Full Version : Omni Slide Menu items from PHP array



zzman
07-16-2008, 09:00 PM
1) Script Title: Omni Slide Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm

3) Describe problem:
I am just trying to populate the menu options from a PHP array, something like this (of course this doesn't work)


<script>
.
.
.
menupos:'top', // set side that menu slides in from (right or left or top)
bartext:'MAIN MENU', // bar text (the vertical cell) use text or img tag
///////////////////////////
menuItems:[
//[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header
["Tickets"], //create header
<?
$stage_arr = $db->DataSet("select * from mt_job_stage");
$ct = 1;
foreach($stage_arr as $arow){
echo '["'.$arow['stage'].'", "work_order_listing.php?sid='.$arow['stage_id'].'"],'
$ct++;
}
?>
["Lois Images", "http://www.loisimages.com", "_new"],
["State Street Blues", "http://www.statestreetbluesstroll.com/","_new"],
["Media Jazz by Night", "http://www.mediajazzbynight.com/", "_new
.
.
.
</script>


Thanks in advance

jscheuer1
07-17-2008, 12:03 AM
PHP doesn't work any differently in javascript than in HTML. The served code must still be valid. Also, at least on most servers, the file containing PHP code must have the .php extension, and be referenced that way by other files that use it. With a javascript served as PHP it is good (but usually not currently required) to declare the mime type with a PHP header.

To see whether or not the served code in a file altered via the use of PHP follows the correct format, just use a browser like Opera or FF and view the file directly via its 'view source' to see how the file is being parsed by the browser.

If you need more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.

zzman
07-17-2008, 01:35 PM
I think i didnt explain the problem properly. all i am trying to do is populate the menu from an php array. Usually something like the code below works


menuItems:[
["Tickets"],
<?
foreach($stage_arr as $arow){
echo '["'.$arow['stage'].'", "work_order_listing.php?sid='.$arow['stage_id'].'"],'
}
?>
...rest of the menu JS


but for some reason here it just give me a blank page, even if i look at the source it blank. So the question is what am i missing

jscheuer1
07-17-2008, 03:08 PM
Sounds like it isn't finding anything to echo. If there is no error, it either isn't parsing on the server side, or there's nothing to parse on the server side. Strict PHP requires a semicolon at the end of a line like echo and at the end of the foreach closure, and a formal opening <?php tag, but none or some that might not matter here. I'm also not certain you got all of the preconditions I laid out in my previous post, though you may. In any case, to be of any real help, I'd want a link to your page:

Please post a link to the page on your site that contains the problematic code so we can check it out.

zzman
07-17-2008, 07:24 PM
i got it going ... I appreciate all the help guys. DD rocks

evan5
10-17-2008, 04:06 AM
how do i go about adding images to omni menu?