loop through an anchor id



PHP Snippet 1:

style="cursor: pointer; ..."

PHP Snippet 2:

style="cursor: poimter; ..."

PHP Snippet 3:

foreach ($subArr as $sub => $result)
{
    if (mysql_num_rows($result) > 0)
    {
       $resultString .= '<a id="'.$sub.'" style="cursor: pointer; color: #0076cf;" href="'.$sub.'">  |  '.$sub.'  |  </a>';
    }
 }

PHP Snippet 4:

foreach ($subArr as $sub => $result)
{
  if (mysql_num_rows($result) > 0)
  {
    $resultString = '<a id="$sub" style="cursor: pointer; color: #0076cf;" href="$sub">'.'  |  '.$sub.'  |  '.'</a>';
  }

  $resultstring="";
}

PHP Snippet 5:

<ul class="menu">
    <li><a href="test">Test</a></li>
    <li><a href="test2">Test 2</a></li>
    <li><a href="test3">Test 3</a></li>
</ul>

PHP Snippet 6:

ul.menu, ul.menu * {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul.menu {
    width: 100%;
    height: 20px;
    background: #ccc;
    padding: 5px 0; /* Add padding top and bottom */
}

ul.menu > li {
    height: 20px;
    line-height: 20px;
    float: left;
}

/* Make a tag fill the entire LI so users can click
anywhere, not just on the text. */
ul.menu > li > a { 
    display: block;
    padding: 0 10px; /* Add padding between items */
    color: #000;
    text-decoration: none;
}

ul.menu > li > a:hover, ul.menu > li > a:active {
    background: #000;
    color: #FFF;
}

/* Add divider between items, except last item (Does not work with earlier versions of IE) */
ul.menu > li:not(:last-child) {
    border-right: 1px solid #000;
}

PHP Snippet 7:

<?php
$subArr = array();
$query = "SELECT something FROM somewhere";
$result = $mysql->query($query);
if($result->num_rows) {
    while($row = $result->fetch_assoc()) { //I personally prefer fetch_assoc over the others, but fetch_row or fetch_array are both fine here too.
        $subArr = $row;
    }
}

//Lets output the menu
$resultString .= '<ul class="menu">';
foreach($subArr as $sub => $result) {
    $resultString .= '<li><a href="' . $result['url'] . '">' . $result['name'] . '</a></li>'
}
$resultString = '</ul>';