Jump to content


Photo

PHP! Excluding 2 lines from WHILE loop


  • Please log in to reply
2 replies to this topic

#1 nygorn

nygorn

    Young Padawan

  • Members
  • Pip
  • 54 posts
  • Gender:Male
  • Location:Sweden

Posted 21 August 2012 - 12:52 PM

Hi.
I'm trying to build this Horizontal dropdown menu in CSS and make it get the menu-options from MySQL database.
The problem i'm having is excluding 2 of the layoutrows from beeing looped.
It's rows number: 23 & 25.
I want row number 24 to be able to repeat between the 23th and 25th line.
If i put number 23 and 25 outside second "While" loop, my menu gets all fu**ed-up :/



<ul id="dropdown">
<?
include 'connect.php';
mysql_select_db("nysa_me", $con);
$result =  mysql_query("
SELECT *
FROM menu_sub
WHERE parent=0
ORDER BY id ASC ") or die(mysql_error());
while($row = mysql_fetch_array($result))
{

echo '<li><a href="'.$row['link'].'">'.$row['name'].'</a>';

mysql_select_db("nysa_me", $con);
$result2 =  mysql_query("
SELECT *
FROM menu_sub
WHERE parent=$row[id]
ORDER BY id ASC ") or die(mysql_error());
while($row2 = mysql_fetch_array($result2))
{
echo '<ul id="sub">';
echo '<li><a href="'.$row2['link'].'">'.$row2['name'].'</a></li>';
echo '</ul>';
}
}
?>
</ul>

Edited by nygorn, 21 August 2012 - 04:10 PM.

  • ruskinoman likes this

#2 ruskinoman

ruskinoman

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 09 September 2012 - 02:33 PM

Добрый день,вы можете подробнее ответить?

#3 JoeyMagz

JoeyMagz

    Young Padawan

  • Members
  • Pip
  • 79 posts
  • Gender:Male
  • Location:Chesapeake, VA

Posted 13 October 2012 - 12:05 AM

I know this is kind of an old topic, but if you're still around looking for an answer I might have it for you. Have you tried placing an If Else statement within the While loop that searches for those 2 rows and displays null for them?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users