1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Alfabetic order error code

Discussion in 'PHP' started by afonseca, Mar 19, 2007.

  1. #1
    Hi all!

    I have an alfabetic order code that lists a number of results that looks like this:

    <?
    $conn = mysql_connect('localhost', 'root', '') or die('ERROR: Unable to connect to database.');
    $db = mysql_select_db('nieto') or die('ERROR: Unable to select database.');
    $sql = 'SELECT produto FROM produto ORDER BY produto';
    $result = mysql_query($sql) or die('ERROR: '.$query.' '.mysql_error());
    $letterlinks = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    echo '<a name="top"></a>';
    echo '<a href="#number">0-9</a> ';
    for ($i = 0; $i < 37; $i++):
    echo '<a href="#'.$letterlinks[$i].'">'.$letterlinks[$i].'</a> ';
    endfor;
    while ($list = mysql_fetch_object($result)):
    $letter = strtoupper(substr($list->produto, 0, 1));

    if ($prev_row != '0-9' && is_numeric($letter)):
    echo '<br /><a name="number"></a><b><u>0-9</u></b> ';
    echo '<a href="top"><i>goto top</i></a><br />';
    $prev_row = '0-9';
    endif;
    if ($letter != $prev_row && !is_numeric($letter)):
    echo '<br /><a name="'.$letter.'"></a><b><u>'.$letter.'</u></b> ';
    echo '<a href="#"><i>top</i></a><br />';
    $prev_row = $letter;
    endif;
    echo $list->produto.'<br />';
    endwhile;
    ?>

    I getting 3 errors that I do not understand:

    1- Notice: Uninitialized string offset: 36 in c:\programas\easyphp1-8\www\nieto\expe.php on line 10

    2-Notice: Undefined variable: prev_row in c:\programas\easyphp1-8\www\nieto\expe.php on line 15

    3- I’m getting repeated alphabetic letters. This is perhaps because of Portuguese Special charset:

    Example I get:

    O
    Ontario

    Ó
    Óntário

    And then again

    O
    Omanel.

    Anyone?

    Thanks
    António
     
    afonseca, Mar 19, 2007 IP
  2. rays

    rays Active Member

    Messages:
    563
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    this will help you get rid of notices
     
    rays, Mar 20, 2007 IP