SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show data from mysql in two columns php

    Hello

    If I have the following code

    if(!isset($_GET['id']))
    {
    $self = $_SERVER['PHP_SELF'];

    $query = "SELECT id, nombre_of FROM oficinas ORDER BY id";
    $result = mysql_query($query) or die('Error : ' . mysql_error());


    $direccion = '<ol>';
    while($row = mysql_fetch_array($result, MYSQL_NUM))
    {
    list($id, $nombre_of) = $row;
    $direccion .= "<li><a href=\"$self?id=$id\">$nombre_of</a></li>\r\n";
    }
    $direccion.= '</ol>';
    As I can do in order that the data in a list with two columns be shown ?

    Sorry, my english is not good
    help me, please!!!!!!!

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ten rows per column:
    Code php:
    if(!isset($_GET['id']))
    {
    $self = $_SERVER['PHP_SELF'];
     
    $query = "SELECT id, nombre_of FROM oficinas ORDER BY id";
    $result = mysql_query($query) or die('Error : ' . mysql_error());
     
     
    $direccion = '<div style="float:left"><ol>';
    $i=1;
    while($row = mysql_fetch_array($result, MYSQL_NUM))
    {
    list($id, $nombre_of) = $row;
    if($i++&#37;10==0) $direccion .= '</ol></div><div style="float:left"><ol>';
    $direccion .= "<li><a href=\"$self?id=$id\">$nombre_of</a></li>\r\n";
    }
    $direccion.= '</ol></div><br style="clear:both" />';
    Saul

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not workink php_daemon

    show list of data 1-9 in order list
    10 - rest unorder list

    and the rest of the list in unorder list, example

    1 *
    2 *
    3 *
    4 *
    5 *
    6 *
    7 *
    8 *
    9 *

    -
    -
    -
    -
    -

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, I was kinda hoping you will adjust it to what you need; it's just the basic idea.
    Saul

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks php_daemon

    solved problem


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •