Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Arranging products in a sort order


Mighty Mike

Recommended Posts

What i am trying to do is give the ability for customers to be able to sort products into a numerical order, 1-10.

 

I am trying to do this within the customers wishlist.

 

Here are my two pcs of code,

 

application_top

 

if ($HTTP_POST_VARS['borrar'] == 2) {
      foreach ($HTTP_POST_VARS['sorting'] as $value) { 
      if (ereg('^[0-9]+$', $value)) {     
      tep_db_query("update " . TABLE_WISHLIST . " set sort_order = '$sort_order' where products_id = '$value' and customers_id = '" . $customer_id . "'");
                } 
          } 
      tep_redirect(tep_href_link(FILENAME_WISHLIST)); 
      }	
 break;

 

And this is the bit from wishlist

    <?php echo tep_draw_input_field('sort_order[]',$products['sort_order']); ?>
   <?php echo tep_draw_hidden_field('sorting[]',$products['products_id']); ?>

 

When i try and update the sort order, it does not give me any error msg's but also does not update and just defaults to 0 :blink:

 

Can anybody see where i am going wrong here

 

Thanks to Dennis for getting me this far :thumbsup:

 

Any help greatly appreciated

 

Thanks

 

Mike

Link to comment
Share on other sites

What i am trying to do is give the ability for customers to be able to sort products into a numerical order, 1-10.

 

I am trying to do this within the customers wishlist.

 

Here are my two pcs of code,

 

application_top

 

if ($HTTP_POST_VARS['borrar'] == 2) {
? ? ? foreach ($HTTP_POST_VARS['sorting'] as $value) { 
? ? ? if (ereg('^[0-9]+$', $value)) { ? ? 
? ? ? tep_db_query("update " . TABLE_WISHLIST . " set sort_order = '$sort_order' where products_id = '$value' and customers_id = '" . $customer_id . "'");
? ? ? ? ? ? ? ? } 
? ? ? ? ? } 
? ? ? tep_redirect(tep_href_link(FILENAME_WISHLIST)); 
? ? ? }	
?break;

 

And this is the bit from wishlist

 ? ?<?php echo tep_draw_input_field('sort_order[]',$products['sort_order']); ?>
? ?<?php echo tep_draw_hidden_field('sorting[]',$products['products_id']); ?>

 

When i try and update the sort order, it does not give me any error msg's but also does not update and just defaults to 0  :blink:

 

Can anybody see where i am going wrong here

 

Thanks to Dennis for getting me this far  :thumbsup:

 

Any help greatly appreciated

 

Thanks

 

Mike

 

 

you will have to explain a little bit more as to how it should work though.

 

<?php echo tep_draw_input_field('sort_order[]',$products['sort_order']); ?>

 

why the [] here ?

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda

 

Thanks for your reply :D

 

OK at the moment customers add products to the Wishlist in no paticular order.

 

I want them to be able to enter in a numerical value so they can put the products in a order.

 

If you add a product to the wishlist it defaults to "0" at the moment.

 

"why the [] here ?"

 

thats the field that needs to be displayed and updated if need be? :blink:

 

if you need to look at the site Wishlist

 

login as

 

[email protected]

pass = tester

 

Thanks

Link to comment
Share on other sites

Hi Amanda

 

Thanks for your reply  :D

 

OK at the moment customers add products to the Wishlist in no paticular order.

 

I want them to be able to enter in a numerical value so they can put the products in a order.

 

If you add a product to the wishlist it defaults to "0" at the moment.

 

"why the [] here ?"

 

thats the field that needs to be displayed and updated if need be?  :blink:

 

if you need to look at the site Wishlist

 

login as

 

[email protected]

pass = tester

 

Thanks

 

ok, I am not so good in passing checkboxes and stuff but here is what I would do:

 

to check the values are really received:

 

if ($HTTP_POST_VARS['borrar'] == 2) {

foreach ($HTTP_POST_VARS['sorting'] as $value) {

if (ereg('^[0-9]+$', $value)) {

echo $sort_order . '-' . $value;

}

}

}

break;

 

and are you sure the query is ok ?

 

tep_db_query("update " . TABLE_WISHLIST . " set sort_order = '$sort_order' where products_id = '$value' and customers_id = '" . $customer_id . "'");

 

 

should not be ?

 

tep_db_query("update " . TABLE_WISHLIST . " set sort_order = '" . $sort_order . "' where products_id = '" . $value . "' and customers_id = '" . $customer_id . "'");

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda

 

Nope no luck there either, did the same thing, if i go into the db and set the sort order there and go back to the website it displays correctly, if i try and update the sort_order values there it resets them all to "0" no error msg's or anything, it just wont accept what i am putting into the field :blink:

 

Anything else you can think off?

 

Thanks

 

Mike :huh:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...