Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ordering Columns HELP

    i have code for order columns like:

    1 2
    3 4

    but i cannot order this whit include template, so how can order whit my template ?

    index.php
    PHP Code:
    <?php
    include("konekcija.php");

    $query mysql_query("select * from news WHERE catid=cat_id AND status = '1'"); 

    $total mysql_num_rows($query); 

    $numRows ceil($total 2); 


    echo (
    '<table border=1>'); 

    for (
    $y 0$y $numRows$y++) { 

        echo (
    '<tr>'); 

        for (
    $x 0$x 2$x++) { 

            if ((
    $offset = ($y + ($x $numRows))) < $total) { 

                
    mysql_data_seek($query$offset); 

                
    $row mysql_fetch_array($query); 
                
    // i wanna put here include file: templates/index.php //
                
    echo ('<td>'.$row['name'].'</td>');
                echo (
    '<td>'.$row['desc'].'</td>'); 
            } 
        } 

        echo (
    '</tr>'); 


    echo (
    '</table>');  
    ?>
    templates/index.php
    PHP Code:
    <style type="text/css">
    .style1 {
        border-width: 0;
        background-color: #FFFFFF;
        color: #000000;
        font-size: 12px;
        font-weight: bold;
    }
    .style2 {
        border-collapse: collapse;
        border: 1px solid #000000;
        background-color: #C0C0C0;
    }
    .style5 {
        border: 1px solid #5589BF;
    }
    .style7 {
        border: 1px solid #008080;
    }
    .style11 {
        border-width: 1px;
    }
    .style12 {
        border-width: 0;
        background-color: #5589BF;
        color: #FFFFFF;
        font-size: 11px;
        font-weight: bold;
    }
    .style13 {
        border-width: 0;
        background-color: #5589BF;
        background-image: url('images/blok.gif');
        text-align: center;
    }
    .style15 {
        color: #5589BF;
    }

    </style>
    </head>

    <body>

    <table style="width: 35%" class="style2" cellspacing="0" cellpadding="2" align="center">
        <tr>
            <td>
            <table style="width: 100%" cellpadding="0" class="style7">
                <tr>
                    <td class="style13" style="width: 400px; color: #FF0000; font-size: 12px; text-align: center; font-weight: bold;"><?=$a1[Name]?>
            </td>
                </tr>
            </table>
            <img src="images/spacer.gif" width="1px" height="3px"></img><table style="width: 100% height: 69px;" cellpadding="0" class="style7">
                <tr>
                    <td class="style1" valign="top">
                    <?=$ItemImage?>
                    </td>
                    <td class="style11">
                    <table style="width: 100%" class="style5">
                        <tr>
                            <td class="style12"><font color="#C0C0C0">Category:</font>&nbsp;<a href="search.php?CategoryID=<?=$a1[catid]?>"><?=$a1[CategoryName]?></a></td>
                        </tr>
                        <tr>
                            <td class="style12"><font color="#C0C0C0">Date:</font>&nbsp;<?=$a1[Date1]?></td>
                        </tr>
                    </table>
                    </td>
                </tr>
            </table>
            <img src="images/spacer.gif" width="1px" height="3px"></img><table style="width: 100%" cellpadding="0" class="style7">
            <tr>
            <td class="style12"><font color="#C0C0C0">Description:</font>&nbsp;<?=nl2br($a1[Desc]);?></td>
            </tr>
            </table>
            </td>
        </tr>
    </table>
    <br />
    <hr style="width: 50%; height: 1px" noshade="noshade" class="style15">
    <br />
    </body>

    </html>

  • #2
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i have try to get this like picture, can someone help me ?

  • #3
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    PHP Code:
    $query mysql_query("select * from news WHERE catid=cat_id AND status = '1'"); 
    The query has no 'ORDER BY'. Choose a column from `news` and place it after the 'ORDER BY'. MySql ordering is DESC by default. If you want to order by asc, place 'ASC' after the column name e.g:

    PHP Code:
    $query mysql_query("select * from news WHERE catid=cat_id AND status = '1' ORDER BY columnName DESC"); 
    Trouble is, I doubt these products are held in the `news` table. The php code and the template html you've posted look unrelated. Please post the php code that applies to your template.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #4
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes code from templates/index.php look unrelated, but need code for looping to get table like picture ?


  •  

    Posting Permissions

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