Jump to content
  • 0

Помогите найти ошибку


skoch244
 Share

Question

$result = mysql_query("SELECT DISTINCT * FROM `q95w65e14` GROUP BY `type_menu`");

while ($bd = mysql_fetch_assoc($result)) {

echo '<div class="left_menu_a">'.$bd[type_menu].'</div>';

$result2 = mysql_query("SELECT * FROM `q95w65e14` WHERE `type_menu`=$bd[type_menu]");

while ($bd2 = mysql_fetch_assoc($result2)) {

echo '<div class="left_menu_b" id="'.$bd2[type_product].'"></div>';

}

}

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
$result = mysql_query("SELECT * FROM `q95w65e14` WHERE `type_menu`='Алкоголь'");while ($bd = mysql_fetch_assoc($result)) {echo $bd[type_product];}

Вот, еще проще, но все равно не выходит, я уже в истерике, хрен знает что делать

Link to comment
Share on other sites

  • 0
$result = mysql_query("SELECT DISTINCT * FROM `q95w65e14` GROUP BY `type_menu`");while ($bd = mysql_fetch_assoc($result)) {echo '<div class="left_menu_a">'.$bd[type_menu].'</div>';$result2 = mysql_query("SELECT * FROM `q95w65e14` WHERE `type_menu`=$bd[type_menu]");while ($bd2 = mysql_fetch_assoc($result2)) {echo '<div class="left_menu_b" id="'.$bd2[type_product].'"></div>';}}

во первых  $bd[type_menu].  в каких то версиях php это позволительно, в других - type_menu, воспринимается как константа, которой у вас нет. поэтому в кавычки заключайте $bd['type_menu'] либо двойные. 

во вторых , когда вы используете части массива в строке, либо разрывайте её конкатенацией, либо возможно оборачивать в фигурные скобки

"SELECT * FROM `q95w65e14` WHERE `type_menu`     = ".$bd['type_menu']либо "SELECT * FROM `q95w65e14` WHERE `type_menu`=   {$bd['type_menu']}"

в третьих, если в таблице type_menu - не число, то в запросе тоже нужно обернуть в кавычки

 

"SELECT * FROM `q95w65e14` WHERE `type_menu`   = '" . $bd['type_menu'] . "'"
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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. See more about our Guidelines and Privacy Policy