Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8800519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:36:37+00:00 2026-06-14T00:36:37+00:00

I have the following code to display some brands per category. <? $con =

  • 0

I have the following code to display some brands per category.

<?
$con = mysql_connect("localhost","baba","passsss");//database connection
mysql_select_db("gr_brands_igi") or die(mysql_error());
mysql_set_charset('utf8',$con);     
$query = "SELECT * FROM brands ORDER BY category_anchor ASC, brand_anchor ASC";

$result = mysql_query($query);

$lasteventname = "";

echo "<table border='0' width='100%' cellspacing='0' cellpadding='0'>";
$cell_ctr = 0;
while($row=mysql_fetch_array($result))
{
    if($row[0] != $lasteventname){
        $title = $row[0];
        $lasteventname = $row[0];
        echo "<tr><td colspan=5><h2>$title</h2></td></tr>";
    }
    if(($cell_ctr % 5) == 4) // 2 is the number of columns
    {
        echo"</tr>";
        echo "<tr>";
        $cell_ctr = 0;
    }
  echo "<td align='justify' cellspacing='2' cellpadding='2'>";
  echo "<h3><a href='http://www.example.com/search/search.asp?txtsearch=$row[2]&catg=$row[3]&intitleanddesc=1&isnavbarsearch=1&gallery=1'>" . $row[2] . "</a></h3>";
  echo "</td>";
  $cell_ctr++;
}

if($cell_ctr == 1)
{
  echo "</tr>";
}
else if($cell_ctr == 2)
{
  echo "</tr>";
}
echo"</table>";
?>

right now it displays this

Jewels

  • 1 2
  • 3 4
  • 5 6
  • 7 8

But i want to order it per column like this:

Jewels

  • 1 5
  • 2 6
  • 3 7
  • 4 8

The fields in the database are:

category_anchor
keyword
brand_anchor
category_id

I have only one while loop and with the $lasteventname i print the category only once

Any Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:36:38+00:00Added an answer on June 14, 2026 at 12:36 am

    is it need to be a table ? for my idea i will do with list items

    <?php
        $result = mysql_query($query);
        $rows = mysql_num_rows($result);
        $i = 0;
    
        echo '<ul>';
    
        while($row=mysql_fetch_array($result))
        {
          if (($i % 4) == 0 && $i > 0) {
            echo '</ul><ul>';
          }
          echo '<li><h3>your code</h3></li>';
          $i++;
        }
    
        echo '</ul>';
    
        ?>
    

    the result will be like this, then you can style it like table as you want

    <div class="banner">
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
    </ul>
    <ul>
      <li>5</li>
      <li>6</li>
      <li>7</li>
      <li>8</li>
    </ul>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $(document).ready(function() { // Manage sidebar category display jQuery(#categories >
i have the following code that generate some images with urls associated from database:
I have the following code that should display some information about ContactLists in a
I have coded the following code(some excerpts of the code) to display a node
I have the following code used to display some user information as well as
I have the following Code to display Data from the Database in XML Document
I have the following code to display the paragraph of a post, after the
I have the following code to display an image in imagebox using EmgucV: Capture
I have the following code: function show(){ var a=document.getElementById('somediv').style.display; a=block; } The above code
I have a following code , I want to display all the attributes of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.