Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

A B C D E F and so on


Aggebones

Recommended Posts

I need help for doing a link bar with all the letters like this:

A B C D E F G H I J K L M N O P Q R S T U V W Z

 

and when you click for example character A you get all profucts of the categorie you are browsing starting with an A...

 

Is there someone who knows how to do this?

 

Thanx!

Link to comment
Share on other sites

now i don't know how to modify oscommerce databases queries yet still new with the script but here is how mysql does it and you will need to build in some error checking

 

SELECT * FROM products WHERE left(productName,1)='$queryletter'

 

 

ie $queryletter = m

 

 

So you would setup links like http://www.oscommercestore.com/search.php?queryletter=m

 

I am thinking this right been while

Link to comment
Share on other sites

I just did it two days ago... This is the exact code, HTML and PHP Combined...

 

 

1) First I made the HTML code to display the letters:

<strong><font face="Georgia, Times New Roman, Times, serif">Artist</font><font face="Georgia, Times New Roman, Times, serif"> 
       Lists: <a href="arthur.php?let=A&osCsid=<? echo $osCsid;?>">A</a> <a href="arthur.php?let=B&osCsid=<? echo $osCsid;?>">B</a> 
       <a href="arthur.php?let=C&osCsid=<? echo $osCsid;?>">C</a> <a href="arthur.php?let=D&osCsid=<? echo $osCsid;?>">D</a> 
       <a href="arthur.php?let=E&osCsid=<? echo $osCsid;?>">E</a> <a href="arthur.php?let=F&osCsid=<? echo $osCsid;?>">F</a> 
       <a href="arthur.php?let=G&osCsid=<? echo $osCsid;?>">G</a> <a href="arthur.php?let=H&osCsid=<? echo $osCsid;?>">H</a> 
       <a href="arthur.php?let=I&osCsid=<? echo $osCsid;?>">I</a> <a href="arthur.php?let=J&osCsid=<? echo $osCsid;?>">J</a> 
       <a href="arthur.php?let=K&osCsid=<? echo $osCsid;?>">K</a> <a href="arthur.php?let=L&osCsid=<? echo $osCsid;?>">L</a> 
       <a href="arthur.php?let=M&osCsid=<? echo $osCsid;?>">M</a> <a href="arthur.php?let=N&osCsid=<? echo $osCsid;?>">N</a> 
       <a href="arthur.php?let=O&osCsid=<? echo $osCsid;?>">O</a> <a href="arthur.php?let=P&osCsid=<? echo $osCsid;?>">P</a> 
       <a href="arthur.php?let=Q&osCsid=<? echo $osCsid;?>">Q</a> <a href="arthur.php?let=R&osCsid=<? echo $osCsid;?>">R</a> 
       <a href="arthur.php?let=S&osCsid=<? echo $osCsid;?>">S</a> <a href="arthur.php?let=T&osCsid=<? echo $osCsid;?>">T</a> 
       <a href="arthur.php?let=U&osCsid=<? echo $osCsid;?>">U</a> <a href="arthur.php?let=V&osCsid=<? echo $osCsid;?>">V</a> 
       </font></strong><font face="Georgia, Times New Roman, Times, serif"><a href="arthur.php?let=W&osCsid=<? echo $osCsid;?>"><strong>W</strong></a><strong> 
       <a href="arthur.php?let=X&osCsid=<? echo $osCsid;?>">X</a> <a href="arthur.php?let=Y&osCsid=<? echo $osCsid;?>">Y</a> 
       <a href="arthur.php?let=Z&osCsid=<? echo $osCsid;?>">Z</a></strong></font>

 

Second The arthur.php page looks something like this:

 

Check if a request was actually sent

if($_GET['let'] == NULL){
$link = "Location: index.php?osCsid=" . $_GET['osCsid'];
header($link);
exit();
} else {

$let = $_GET['let'];
$osCsid = $_GET['osCsid'];
}

 

include databases and other thingis:

 

 require('includes/application_top.php');


 require(DIR_WS_INCLUDES . 'header.php');

 

Start Page:

 

<html>
<head>
<title>Find By Artist - Letter:<? echo $let;?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-1256-1">
</head>

<body>
<table width="650" cellspacing="0" cellpadding="0">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top">
<p> </p><tr>
 <table width="750" border="2" align="center" cellpadding="0" cellspacing="0">
   <tr>
   <td width="52" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
 </table></td>
     <td width="690" valign="top"><table width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td> </td>
         </tr>
       </table> 
       <? 
 $query = "SELECT * FROM manufacturers WHERE `manufacturers_name` LIKE '$let%'";
 $results = @mysql_query($query);
 

 $found = false;
   
 
 ?><table width="70%" border="5" align="center" cellpadding="5" cellspacing="0">
         <tr> 
           <td colspan="2" bgcolor="#0000FF"> <div align="center"><strong><font color="#FFFFFF" face="Georgia, Times New Roman, Times, serif">Click 
               On The Appropriate Artist For Their Songs:</font></strong></div></td>
         </tr>
         <tr> 
           
          
  <?
   while ($row = mysql_fetch_array($results, MYSQL_NUM)) { ?>
         <tr>
           <td colspan="2"><div align="center"><strong><font face="Georgia, Times New Roman, Times, serif"><a href="index.php?manufacturers_id=<? echo $row[0];?>&osCsid=<? echo $osCsid;?>"><? echo $row[1];?></a></font></strong></div></td>
         </tr>
   
   <? $found = true; }
   
   if($found == false){ ?>
    <td colspan="2"><div align="center"><strong><font face="Georgia, Times New Roman, Times, serif">There 
               are Currently No Authors For This List, Please Choose Another 
               One</font></strong></div></td>
         </tr> <? } ?>
       </table>
     <p> 
  
  </p></td>
 </tr>
</table>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'footer.php'); 
require(DIR_WS_INCLUDES . 'application_bottom.php'); 
?>

Any questions u can ask..

 

Peace,

--------------------------------

Link to comment
Share on other sites

I copy and pasted that start page code and saved as arthur.php and got this error:

 

Warning: main(DIR_WS_INCLUDEScolumn_left.php): failed to open stream: No such file or directory in /home/krazyowl/public_html/catalog/arthur.php on line 16

 

Fatal error: main(): Failed opening required 'DIR_WS_INCLUDEScolumn_left.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/krazyowl/public_html/catalog/arthur.php on line 16

Link to comment
Share on other sites

I have problems with this:

 

?$query = "SELECT * FROM manufacturers WHERE `manufacturers_name` LIKE '$let%'";

?$results = @mysql_query($query);

 

 

is that file supposed to me named authur.php?

Link to comment
Share on other sites

Ok, everyone seems to be very confused...

 

To do this you should haev knowledge in PHP and MYSQL...

 

These are the steps i took to do it:

 

Step (1a) -- ADD THE A B C D E F G ...... in the header (or anywhere else where u want to diplay the list)....

 

(1b) The A, B , C , Should be linked to the arthur.php with the variable let (represent letter) and the Session Id..E.G:

 

<a href="arthur.php?let=A&osCsid=<?echo $osCsid;?>A</a>

 

 

I hope that no one has problems with those steps....

 

 

Step (2)

 

Make the arthur.php file, the way you want it to look (i made it look just like all the other pages (just copied one and cleared the content)..

 

Make Sure that the File has all the includes that are required to connect the database and all other global variables:

 

require('includes/application_top.php');
require(DIR_WS_INCLUDES . 'header.php');

 

Next we make the coding for the content of the arthur file... All we are going to do is retrieve all the authors that their name start with A, by using the MYSQL phrase Like $let% -----> % allows to get anything that starts with $let. We use these queries:

 

$query = "SELECT * FROM manufacturers WHERE `manufacturers_name` LIKE '$let%'";
$results = @mysql_query($query);

 

$results will contain the array of names that were fetched...

 

To output those names you will have to loop thru the whole $results, which will include the manfacture name, url (with session id), $row[0] will contain the ID and $row[1] will contain the name:

 

 

while ($row = mysql_fetch_array($results, MYSQL_NUM)) { 

<a href="index.php?manufacturers_id=<? echo $row[0];?>&osCsid=<? echo $osCsid;?>"><? echo $row[1];?></a></

}

 

 

Thats it????

 

I hope you guys get it now..

 

BTW..... These are missing from the explanation:

1) Table structure to hold names,

2) Checker to see if list is empty,

3) Check if the page was infact called with a letter not out of curiosity

 

Salam,

--------------------------------

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...