Jump to content

Recommended Posts

hi,

 

i need help, i have a page wherein the result listing needs to be displayed in 2 columns.

let say i have a total count of 10, the first 5 will be displayed in the first column and the

remaining 5 will be displayed in the next column.

this is my current code and i cant seem to make it work

 

<?			$uSql = "SELECT * FROM jos_classifieds_categories WHERE parent = '$id' AND published=1 LIMIT 0,5";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
		echo 'no data found';
		}else{
		while($uRow = mysql_fetch_array($uResult)){
		$name = $uRow["name"];
		$subid = $uRow["id"];
echo "
<table width='600' border='0' cellspacing='3' cellpadding='0'>
  <tr>
    <td><a href='test.php?id=$id&subid=$subid&view=subview'>$name</a></td>
    <td><a href='test.php?id=$id&subid=$subid&view=subview'>$name</a></td>
  </tr>
</table>

";
}
}
?>

 

hope you could help me with this.

 

thanks!

hi,

 

i found a code that displays result in 2 columns but i still cant make it work

 

normally what i wanted to happen is if i have 10 results

the display will look like this

 

result1      result6

result2      result7

result3      result8

result4      result9

result5      result10

 

and currently this is the code that i have

 

<?php

$columns = 2;

$sql = "SELECT * FROM jos_classifieds_providers WHERE published=1";     


   
$result = mysql_query($sql) or die("Couldn't execute query."); 

$num_rows = mysql_num_rows($result); 

$rows = ceil($num_rows / $columns); 

while($row = mysql_fetch_array($result)) {  
$data[] = $row['name'];  
$data1[] = $row['address'];  
$data2[] = $row['postalcode']; 

} 

echo "<table border='0'>n"; 

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

for($j = 0; $j < $columns; $j++) {    
if(isset($data[$i + ($j * $rows)])) {   
  echo "<td><img src="" . $data[$i + ($j * $rows)] . ""></td>n";        
  echo "<td valign="top">" . $data1[$i + ($j * $rows)] . "<br>" . $data2[$i + ($j * $rows)] . "</td>n";
      }
        } 
  echo "</tr>n";
  }    
  echo "</table>n"; 
  ?> 

 

 

but i am getting an error

Parse error: parse error, unexpected '\"', expecting ',' or ';' in /var/www/html/myoochi/findit/test2.php on line 29

 

and this is my testpage link

http://mango.resonance.com.sg/myoochi/findit/test2.php

 

 

 

hope you could help me with this.

 

thanks!

 

try

<?php

$columns = 2;

$sql = "SELECT * FROM jos_classifieds_providers WHERE published=1";     


   
$result = mysql_query($sql) or die("Couldn't execute query."); 

$num_rows = mysql_num_rows($result); 

$rows = ceil($num_rows / $columns); 

while($row = mysql_fetch_array($result)) {  
$data[] = $row['name'];  
$data1[] = $row['address'];  
$data2[] = $row['postalcode']; 

} 

echo "<table border='0'>\n"; 

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

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

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.