Jump to content

Archived

This topic is now archived and is closed to further replies.

jwwceo

I'm going to commit sue.....

Recommended Posts

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 DATABASE
while($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 PRODUCT
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]

Share this post


Link to post
Share on other sites
[code]<?php
//CREATES A LOOP THAT OUTPUTS THE FOLLOWING HTML FOR EACH ROW IN THE DATABASE
while($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
echo "<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 PRODUCT
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]

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]

Share this post


Link to post
Share on other sites
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????

Share this post


Link to post
Share on other sites
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.

}

OR

foreach($array as $array_value)
{
  //Array value is now a local var.
}

Also read up on arrays.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.