jwwceo Posted August 29, 2006 Share Posted August 29, 2006 I am trying to make a product page that will create custom javascript menus for each item on the page. There will be a little icon that once rolled over will make a pop up menu with the keywords for that shirt.The javascript menu I'm using has a block of HTML in the body for each menu. The following code is what I've came up with to build these HTML tables for each menu. I only posted the relevant code...I think....I think once I get his part done I can get the rest....I get major parse errors... any ideas....is the logic even right???[code]//CREATES A LOOP THAT OUTPUTS THE FOLLOWING HTML FOR EACH ROW IN THE DATABASEwhile($info = mysql_fetch_array($data)){ //PULLS THE KEYWORD DATA FOR EACH ITEM(ROW)$data1 = mysql_query("SELECT * FROM shirtkeywords WHERE shirt_id ='".$info['shirt_id']."') or die(mysql_error());$keywords = mysql_fetch_array( $data1 ));//BUILD THE JAVASCRIPT HEADER FOR EACH MENU"<DIV class=menuContainer id=menu$info[shirt_id]Container><DIV class=menu id=menu$info[shirt_id]Content><DIV class=menuInsert style='HEIGHT: 180px'><TABLE class=menuTable cellSpacing=0 cellPadding=0 border=0><TBODY>";//BUILD THE TABLE ROWS FOR EACH KEYWORD ASSOCIATED WITH A PRODUCTforeach ($keywords[] as $keyword_id) {echo"<TR> <TD><IMG height=4 src='menu_script/spacer.gif' width=1></TD></TD> <TR> <TD><A class=menuLink href='link'>".keywords['keyword']."</A></TD></TR> </TBODY></TABLE></DIV></DIV></DIV>";}[/code] Link to comment https://forums.phpfreaks.com/topic/18975-im-going-to-commit-sue/ Share on other sites More sharing options...
448191 Posted August 29, 2006 Share Posted August 29, 2006 [code]<?php//CREATES A LOOP THAT OUTPUTS THE FOLLOWING HTML FOR EACH ROW IN THE DATABASEwhile($info = mysql_fetch_array($data)){ //PULLS THE KEYWORD DATA FOR EACH ITEM(ROW)$data1 = mysql_query('SELECT * FROM shirtkeywords WHERE shirt_id ="'.$info['shirt_id'].'"') or die(mysql_error());$keywords = mysql_fetch_array( $data1 );//BUILD THE JAVASCRIPT HEADER FOR EACH MENUecho "<DIV class=menuContainer id=menu$info[shirt_id]Container><DIV class=menu id=menu$info[shirt_id]Content><DIV class=menuInsert style='HEIGHT: 180px'><TABLE class=menuTable cellSpacing=0 cellPadding=0 border=0><TBODY>";//BUILD THE TABLE ROWS FOR EACH KEYWORD ASSOCIATED WITH A PRODUCTforeach ($keywords[] as $keyword_id) { echo '<TR><TD><IMG height="4" src=\'menu_script/spacer.gif\' width="1"></TD></TD> <TR><TD><A class="menuLink" href=\'link>'.$keywords['keyword'].'</A></TD></TR> </TBODY> </TABLE></DIV></DIV></DIV>';}?>[/code]I fixed the parse errors for you.I don't quite see what you're trying to do here:[code]foreach ($keywords[] as $keyword_id) { echo '<TR><TD><IMG height="4" src=\'menu_script/spacer.gif\' width="1"></TD></TD> <TR><TD><A class="menuLink" href=\'link>'.$keywords['keyword'].'</A></TD></TR> </TBODY> </TABLE></DIV></DIV></DIV>';}[/code] Link to comment https://forums.phpfreaks.com/topic/18975-im-going-to-commit-sue/#findComment-82026 Share on other sites More sharing options...
jwwceo Posted August 29, 2006 Author Share Posted August 29, 2006 I may not be using that foreach right.The idea is that I store all the keywords and their keyword id's that apply to a shirt in an array called $keywords.Then for each item in the array I output another row in the table...would a while loop be better???? Link to comment https://forums.phpfreaks.com/topic/18975-im-going-to-commit-sue/#findComment-82027 Share on other sites More sharing options...
448191 Posted August 29, 2006 Share Posted August 29, 2006 This is VERY basic stuff, so you might wanna take a look in the manual. foreach($array as $array_key => $array_value){ //Array key and array value are now local variables, wich you may use.}ORforeach($array as $array_value){ //Array value is now a local var.}Also read up on arrays. Link to comment https://forums.phpfreaks.com/topic/18975-im-going-to-commit-sue/#findComment-82028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.