Jump to content

[SOLVED] need help in my column display


pixeltrace

Recommended Posts

hi,

 

i need help, i have a list page that has pagination and

the list should be displayed in 5 columns.

unfortunately, i cant make the column display work

this is the link

http://ideas-people.com/engsoon/brands.php

 

and this is my current code

<?
include 'admean/db_connect.php';
include("admean/pagina/my_pagina_class.php");


$letter = '';
if (isset($_GET['sort'])) {
  if($_GET['sort'] != ''){
$letter = "WHERE substring(brand_name,1,1) = '". $_GET['sort'] ."'";

  }
}

$test = new JHpage;
$test->sql = "SELECT * FROM engsoon_brands ".$letter."";
//$test->sql = "SELECT * FROM engsoon_brands ORDER BY ".$sort1 ." ".$sort3." ".$sort2." ";

// the (basic) sql statement (use the SQL whatever you like)
$result = $test->get_page_result(); // result set
$num_rows = $test->get_page_num_rows(); // number of records in result set 
$nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)
$nav_info = $test->page_info(); // information about the number of records on page ("to" is the text between the number)
$simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images
$total_recs = $test->get_total_rows(); // the total number of records
?>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table width="500" border="0" cellspacing="4" cellpadding="0">
  <tr>
    <td><span class="h2">Our Brands</span></td>
  </tr>
  <tr>
    <td>view brands by alphabetical order </td>
  </tr>
  <tr>
    <td>total record found:<?php echo " " .$total_recs; ?>
</td>
  </tr>
  <tr>
    <td><a href="brands.php?id=2&sort=">All</a> <a href="brands.php?id=2&sort=A">A</a> <a href="brands.php?id=2&sort=B">B</a> <a href="brands.php?id=2&sort=C">C</a> <a href="brands.php?id=2&sort=D">D</a> <a href="brands.php?id=2&sort=E">E</a> <a href="brands.php?id=2&sort=F">F</a> <a href="brands.php?id=2&sort=G">G</a> <a href="brands.php?id=2&sort=H">H</a> <a href="brands.php?id=2&sort=I">I</a> <a href="brands.php?id=2&sort=J">J</a> <a href="brands.php?id=2&sort=K">K</a> <a href="brands.php?id=2&sort=L">L</a> <a href="brands.php?id=2&sort=M">M</a> <a href="brands.php?id=2&sort=N">N</a> <a href="brands.php?id=2&sort=O">O</a> <a href="brands.php?id=2&sort=P">P</a> <a href="brands.php?id=2&sort=Q">Q</a> <a href="brands.php?id=2&sort=R">R</a> <a href="brands.php?id=2&sort=S">S</a> <a href="brands.php?id=2&sort=T">T</a> <a href="brands.php?id=2&sort=U">U</a> <a href="brands.php?id=2&sort=V">V</a> <a href="brands.php?id=2&sort=W">W</a> <a href="brands.php?id=2&sort=X">X</a> <a href="brands.php?id=2&sort=Y">Y</a> <a href="brands.php?id=2&sort=Z">Z</a></td>
  </tr>
  <tr>
    <td>
<?
$columns = 5; //change the number of column

for ($i = 0; $i < $num_rows; $i++) {
$brands_logo = mysql_result($result, $i, "brands_logo");
$bid = mysql_result($result, $i, "bid");
//$brand_name = mysql_result($result, $i, "brand_name");
		$rows = ceil($num_rows / $columns); 
		$data[] = $brands_logo; 
		$data1[] = $bid; 

echo "<table width='500' border='0' cellspacing='3' cellpadding='0'>\n";

echo "<tr>\n";        

for($j = 0; $j < $columns; $j++) {    
if(isset($data[$i + ($j * $rows)])) {   
  echo "<td><img src=\"../engsoon/images/brandlogo/" . $data[$i + ($j * $rows)] . "\"width='100' height='100'". "></td>\n";        
  echo "<td valign=\"top\">" . $data1[$i + ($j * $rows)] . "</td>\n";
      }
        } 
  echo "</tr>\n";
  }    
  echo "</table>\n"; 
?>

</td>
  </tr>
  <tr>
    <td align="right">
<? echo "<span>".$nav_links."</span>";	?>
</td>
  </tr>
</table>
</body>
</html>

 

 

hope you could help me fix this

 

thanks so much!

Link to comment
Share on other sites

hi,

 

any help on this?

i tried fixing it.

i set the column to 5 but its displaying the wrong way

and its repeating the items

 

http://ideas-people.com/engsoon/brands.php

 

this is the current code i have now

<?
include 'admean/db_connect.php';
include("admean/pagina/my_pagina_class.php");


$letter = '';
if (isset($_GET['sort'])) {
  if($_GET['sort'] != ''){
$letter = "WHERE substring(brand_name,1,1) = '". $_GET['sort'] ."'";

  }
}

$test = new JHpage;
$test->sql = "SELECT * FROM engsoon_brands ".$letter."";
//$test->sql = "SELECT * FROM engsoon_brands ORDER BY ".$sort1 ." ".$sort3." ".$sort2." ";

// the (basic) sql statement (use the SQL whatever you like)
$result = $test->get_page_result(); // result set
$num_rows = $test->get_page_num_rows(); // number of records in result set 
$nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)
$nav_info = $test->page_info(); // information about the number of records on page ("to" is the text between the number)
$simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images
$total_recs = $test->get_total_rows(); // the total number of records
?>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table width="500" border="0" cellspacing="4" cellpadding="0">
  <tr>
    <td><span class="h2">Our Brands</span></td>
  </tr>
  <tr>
    <td>view brands by alphabetical order </td>
  </tr>
  <tr>
    <td>total record found:<?php echo " " .$total_recs; ?>
</td>
  </tr>
  <tr>
    <td><a href="brands.php?id=2&sort=">All</a> <a href="brands.php?id=2&sort=A">A</a> <a href="brands.php?id=2&sort=B">B</a> <a href="brands.php?id=2&sort=C">C</a> <a href="brands.php?id=2&sort=D">D</a> <a href="brands.php?id=2&sort=E">E</a> <a href="brands.php?id=2&sort=F">F</a> <a href="brands.php?id=2&sort=G">G</a> <a href="brands.php?id=2&sort=H">H</a> <a href="brands.php?id=2&sort=I">I</a> <a href="brands.php?id=2&sort=J">J</a> <a href="brands.php?id=2&sort=K">K</a> <a href="brands.php?id=2&sort=L">L</a> <a href="brands.php?id=2&sort=M">M</a> <a href="brands.php?id=2&sort=N">N</a> <a href="brands.php?id=2&sort=O">O</a> <a href="brands.php?id=2&sort=P">P</a> <a href="brands.php?id=2&sort=Q">Q</a> <a href="brands.php?id=2&sort=R">R</a> <a href="brands.php?id=2&sort=S">S</a> <a href="brands.php?id=2&sort=T">T</a> <a href="brands.php?id=2&sort=U">U</a> <a href="brands.php?id=2&sort=V">V</a> <a href="brands.php?id=2&sort=W">W</a> <a href="brands.php?id=2&sort=X">X</a> <a href="brands.php?id=2&sort=Y">Y</a> <a href="brands.php?id=2&sort=Z">Z</a></td>
  </tr>
  <tr>
    <td>
<?
$columns = 5; //change the number of column
while($row = mysql_fetch_array($result)) {  
		$rows = ceil($num_rows / $columns); 
		$data[] = $row['brands_logo']; 
		$data1[] = $row['bid']; 
}

echo "<table width='500' border='0' cellspacing='3' cellpadding='0'>\n";


for ($i = 0; $i < $num_rows; $i++) {
echo "<tr>\n";        

for($j = 0; $j < $columns; $j++) {    
if(isset($data[$i + ($j * $rows)])) {
$bid =  $data1[$i + ($j * $rows)];  
  echo "<td><a href ='brands.php?id=1&bid=$bid'><img src=\"../engsoon/images/brandlogo/" . $data[$i + ($j * $rows)] . "\"width='70' height='70'". "></a></td>\n";        
      }
        } 
  echo "</tr>\n";
  }    
  echo "</table>\n"; 
?>

</td>
  </tr>
  <tr>
    <td align="right">
<? echo "<span>".$nav_links."</span>";	?>
</td>
  </tr>
</table>
</body>
</html>

 

hope you could help me on this.

 

thanks so much!

Link to comment
Share on other sites

Try the following

<?php
include 'admean/db_connect.php';
include 'admean/pagina/my_pagina_class.php';

$letter = '';

if (isset($_GET['sort']))
{
    if($_GET['sort'] != '')
    {
        $letter = "WHERE substring(brand_name,1,1) = '" . $_GET['sort'] . "'";
    }
}

$test = new JHpage;
$test->sql = "SELECT * FROM engsoon_brands ".$letter."";
//$test->sql = "SELECT * FROM engsoon_brands ORDER BY ".$sort1 ." ".$sort3." ".$sort2." ";

// the (basic) sql statement (use the SQL whatever you like)
$result = $test->get_page_result(); // result set
$num_rows = $test->get_page_num_rows(); // number of records in result set
$nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)
$nav_info = $test->page_info(); // information about the number of records on page ("to" is the text between the number)
$simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images
$total_recs = $test->get_total_rows(); // the total number of records
?>
<table width="500" border="0" cellspacing="4" cellpadding="0">
  <tr>
    <td><span class="h2">Our Brands</span></td>
  </tr>
  <tr>
    <td>view brands by alphabetical order </td>
  </tr>
  <tr>
    <td>total record found:<?php echo " " .$total_recs; ?>
</td>
  </tr>
  <tr>
    <td><a href="brands.php?id=2&sort=">All</a> <a href="brands.php?id=2&sort=A">A</a> <a href="brands.php?id=2&sort=B">B</a> <a href="brands.php?id=2&sort=C">C</a> <a href="brands.php?id=2&sort=D">D</a> <a href="brands.php?id=2&sort=E">E</a> <a href="brands.php?id=2&sort=F">F</a> <a href="brands.php?id=2&sort=G">G</a> <a href="brands.php?id=2&sort=H">H</a> <a href="brands.php?id=2&sort=I">I</a> <a href="brands.php?id=2&sort=J">J</a> <a href="brands.php?id=2&sort=K">K</a> <a href="brands.php?id=2&sort=L">L</a> <a href="brands.php?id=2&sort=M">M</a> <a href="brands.php?id=2&sort=N">N</a> <a href="brands.php?id=2&sort=O">O</a> <a href="brands.php?id=2&sort=P">P</a> <a href="brands.php?id=2&sort=Q">Q</a> <a href="brands.php?id=2&sort=R">R</a> <a href="brands.php?id=2&sort=S">S</a> <a href="brands.php?id=2&sort=T">T</a> <a href="brands.php?id=2&sort=U">U</a> <a href="brands.php?id=2&sort=V">V</a> <a href="brands.php?id=2&sort=W">W</a> <a href="brands.php?id=2&sort=X">X</a> <a href="brands.php?id=2&sort=Y">Y</a> <a href="brands.php?id=2&sort=Z">Z</a></td>
  </tr>
  <tr>
    <td>
<?php


echo "<table width=\"500\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\">\n";

$columns = 5; //change the number of column
$cur_col = 1; // current column counter

while($row = mysql_fetch_assoc($result))
{
    $brand_logo  = $row['brand_logo'];
    $big         = $row['bid'];

    $tbl_cols = <<<EOF
echo "<td><a href="brands.php?id=1&bid=$bid"><img src="../engsoon/images/brandlogo/$brand_logo" width="70" height="70"></a></td>;
EOF;

    if($cur_col == 1)
    {
        echo "<tr>\n" . $tbl_cols . "\n"; // add table row for new column
    }
    elseif($cur_col < $columns)
    {
        echo $tbl_cols . "\n"; // add in a column
    }
    elseif($cur_col == $columns)
    {
        echo $tbl_cols . "</tr>\n";  // close table row
        $cur_col = 0; // reset current column count
    }

    $cur_col++; // increase curent column couunt by 1
}

echo "</table>\n";
?>

</td>
  </tr>
  <tr>
    <td align="right">
<?php echo "<span>".$nav_links."</span>";?>
</td>
  </tr>
</table>
</body>
</html>

It is untested.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.