Jump to content

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


jwwceo
 Share

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]
Link to comment
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]
Link to comment
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????
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

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.