need help with incremented numbers (php/mysql) [menus + accesskeys]

General questions relating to Joomla! There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
sa247
Joomla! Explorer
Joomla! Explorer
Posts: 271
Joined: Sat Sep 16, 2006 8:50 pm
Location: San Antonio, Texas
Contact:

need help with incremented numbers (php/mysql) [menus + accesskeys]

Post by sa247 » Wed Jul 25, 2007 5:00 am

i am trying to create a menu system for a dot mobi site and need to use accesskeys

I have got my results back fine and now i am trying to format them to display properly - i did have them working as i wanted at one point and then *ahem* over wrote the code and had to start all over again.....

this is where i am now and i have come to a brick wall... this is how i want my results to look...

[1] Home
[2] About Us
etc
etc

Each item title being a link - I need the [1] and [2] [etc] to increment per row result and will also need the same number to be inserted into the link as an accesskey="x"

Hope that makes sense....

The code i been have working on without the incremented numbers looks like this...

Code: Select all

function getMobimenus() {
  global $database;
        $sql = 'SELECT * FROM jos_menu WHERE menutype = \'mobimenu\' AND published = 1 ORDER BY ordering ASC';
        $database->setQuery( $sql );
        $rows = $database->loadObjectList();
        foreach ( $rows as $row )     
  echo "[**** need incremented number here****] <a href=\"$row->link\" accesskey=\"**** need incremented number here****\">$row->name</a><br/>\n";  
  } 
getMobimenus();
I found the looping example on w3schools website but couldnt figure out how to get the following code to work with the above...

Code: Select all

$i=1;
while($i<=5)
  {
  echo "[" . $i . "]";
  $i++;
  }
perhaps im missing something blindingly obvious but any input would be greatly appreciated

also i found a similar example on another site

Code: Select all

$result = mysql_query($sql);
$thenumber = 1;
while ($row = mysql_fetch_array ($result)) {
    echo $thenumber . ' - ' . $row['name'];
     $thenumber++;
}
but i think the mysql functions arent responding when i run it joomla...
Last edited by sa247 on Wed Jul 25, 2007 5:05 am, edited 1 time in total.

User avatar
jalil
Joomla! Guru
Joomla! Guru
Posts: 925
Joined: Wed Jul 04, 2007 4:54 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: need help with incremented numbers (php/mysql) [menus + accesskeys]

Post by jalil » Wed Jul 25, 2007 8:38 am

sent you a pm as i think this is a bit too heavy for a general discussion. but if others think otherwise i'd gladly post here.


Locked

Return to “General Questions - 1.0.x”