Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Wont sort on product name


mondeo79

Recommended Posts

Posted

I have added some fields and tables to my OSC to allow me to have directors and stars fields listed - below is the code I use to allow to show a page showing all the titles by one particular director. At the moment it works fine but I cant get it to sort by product_name - I think the problem is that product_name is in products_description and not products but I cant figure out how to call products_name and to then sort by it

 

Any help please?

 

Thanks

 

Jase

 

 

<?php

$directorsinput = $HTTP_GET_VARS[directors_id];

if(!$directorsinput) {

$i = 1; 

$sql4 = "select * from directors ORDER by directors_name"; 
$result4 = mysql_query($sql4); 

$num_directors = mysql_num_rows($result4); 
$num_columns = 3; 

$idx = 1; 
$num_rows = $num_directors / $num_columns; 

// Place the customers in the proper columns / rows. 

while ($row4 = mysql_fetch_array($result4)) 
{ 
 $row_id = $idx % $num_rows; 
 $row[$row_id] .= "<td class=main width=200><a href=\"directors.php?directors_id=" . $row4['directors_id'] . "\">$row4[directors_name]</a></td>"; 

 $idx++; 
} 

// Print the whole thing now. 

echo ("<table>"); 

foreach ($row as $cur_row) 
{ 
 echo ("<tr>" . $cur_row . "</tr>\n"); 
} 

echo ("<tr><td colspan=4> </td></tr></table>");


} else {

if($directorsinput!=''){
//$sql = "select * from products where directors_id='$directorsinput'";
$sql = "select * from products where directors_id='$directorsinput'";

$result = mysql_query($sql)or die(mysql_error());

$sql3 = "SELECT * FROM directors WHERE directors_id = '$directorsinput'";
$result3 = mysql_query($sql3);
$row3 =  mysql_fetch_array($result3);

?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
     <td class="pageHeading">
	 DIRECTORS PAGE: 
	 <?php
   echo $row3[directors_name];
	 ?>
 </td>

    <td class="pageHeading" align="right"></td>
  </tr>
</table></td>
     </tr>
<tr>
<td>

<?php

echo "<table border=0 cellspacing=10 width=100%>";

$counter = 1;
echo "<tr>";
while ($row = mysql_fetch_array($result)) {

$prod_id = $row[products_id];
$sql2 = "SELECT * from products_description WHERE products_id = '$prod_id'";
$result2 = mysql_query($sql2);
$row2 =  mysql_fetch_array($result2);

$pic=$row[products_image];

if($counter > 3){
    $counter = 1;
    echo "<tr>";
}

echo "<td align=center width=33% class=productListing-data valign=top>";
echo "<a href=product_info.php?products_id=$row[products_id]>";
echo tep_image(DIR_WS_IMAGES . $pic, $row2[products_name], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
echo "</a>";
echo "<br>";
echo "<a href=product_info.php?products_id=$row[products_id]>$row2[products_name]</a>";
echo "<br>";
$price = $row[products_price];
$price = substr($price, 0, -2);
echo "?".$price." Delivered";
echo "<br>";
?>
<a href="http://www.r18dvdshop.co.uk/catalog/index.php?cPath=1&sort=2a&action=buy_now&products_id=<? echo $prod_id;  ?>">
<img src="includes/languages/english/images/buttons/button_buy_now.gif" border="0" alt="Buy Now" title=" Buy Now "></a>
<?
echo "</td>";
if($counter == 3) {
     echo "</tr>";

}

$counter++;
}

echo "</table>";

}

?>

</td>
</tr>

<?php
}
?>

     <tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  <tr class="infoBoxContents">
    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
 <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
      </tr>
    </table></td>
  </tr>
</table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...