chrometweaks.org

Free iPage hosting service taking bits of my files away?

Click Here To View All Answers...


Quick question... Free iPage hosting service taking bits of my files away? Hoping for any answer or 2. Second question.. <?php $prod_quantity = tep_get_products_stock($products_id);.

Switch ($prod_quantity) {.

Case 0:.

Print '<img src="images/stock_soldout.gif" border="0">';.

Break;.

Case 1:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case 2:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case 3:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case 4:.

Print '<img src="images/stock_instock.gif" border="0">';.

Break;.

Case 120:.

Print '<img src="images/stock_instock.gif" border="0">';.

Break;.

} ?>.

This is a piece of code from an existing and already running contribution, but I would like to tweak it a bit, but don't know how..

Hopefully someone can rewrite it a bit, because basically what I have to do now would be to make an entry for every step of the quantity available..

Which is not so bad if you only have 1 to 10 products, but if you have large amounts on stock [100dreds], this would create a HUGE column in the products info page ..

I don't know if this would make the iPage site or page slow ????.

But what I am thinking of is to make like 3 states from the above piece of code, which would have to be something like this :.

Case below 1 :.

Print '<img src="images/stock_soldout.gif" border="0">';.

Break;.

Case below 10 [but above 0] :.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case above 10 :.

Print '<img src="images/stock_onstock.gif" border="0">';.

Break;.

I know the code I wrote above is aboslutely nonsense, but that is because I don't know jack about codes.

ANyone knows the solution?..

Comments (217)

I'm stumped. I'm not so sure what is the answer to that question. I'll do some investigation and get back to you if I got an decent answer. You should email the people at iPage as they probably could answer your iPage question..

Comment #1

Thanks yesudo ..

I have tried your code , but when I just copy pasted the code it gave me an eror.:.

Parse error: parse error, unexpected '}' in /home/storename/www/shop/product_info.php on line 237.

Which is in this part of the code :.

Print '<img src="images/stock_soldout.gif" border="0">';.

<?php}.

I saw that parts of the code in dreamweaver where marked as blue [which means something is wrong] when I put an extra space between the ? and the } the code became red [which in dreamweaver means is a correct code].

SO now the code is :.

<?php.

If ($prod_quantity < 1){?>.

Print '<img src="images/stock_soldout.gif" border="0">';.

<?php }.

Elseif (($prod_quantity > 0) && ($prod_quantity < 10){?>.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

<?php }.

Else{?>.

Print '<img src="images/stock_onstock.gif" border="0">';.

<?php }?>.

However, it still didn't work, itstead now it comes up with a :.

Parse error: parse error, unexpected ';' in /home/storename/www/shop/product_info.php on line 238.

This is in this line :.

Elseif (($prod_quantity > 0) && ($prod_quantity < 10){?>.

Any ideas what could be wrong?.

Thanks for your time and help.

This post has been edited by.

PVK.

: 02 July 2004, 08:46..

Comment #2

<?php.

If ($prod_quantity < 1) {.

Echo "<img src=\"images/stock_soldout.gif\" border="0">";.

Elseif (($prod_quantity > 0) && ($prod_quantity < 10)) {.

Echo "<img src=\"images/stock_limitedstock.gif\" border="0">";.

} else {.

Echo "<img src=\"images/stock_onstock.gif\" border="0">";.

}.

?>.

Or ....

<?php.

 if ($prod_quantity < 1) {.

   echo "<img src=\"images/stock_soldout.gif\" border=\"0\">";.

 elseif (($prod_quantity > 0) && ($prod_quantity < 10)) {.

   echo "<img src=\"images/stock_limitedstock.gif\" border=\"0\">";.

 } else {.

   echo "<img src=\"images/stock_onstock.gif\" border=\"0\">";.

 }.

?>.

This post has been edited by.

Acheron.

: 02 July 2004, 09:12..

Comment #3

ALmost there I think..

I still got errors with Acherons version, but after some tweaking I got no erros and even got to display one of the images..

What follows is a code from an absolutel noob when it comes to code, but it is a trial and error effort from my side.

<?php.

If ($prod_quantity < 1 {.

Echo "<img src=\"images/stock_limitedstock.gif\" border=\"0\">";.

} elseif (($prod_quantity > 0) && ($prod_quantity < 10)) {.

Echo "<img src=\"images/stock_limitedstock.gif\" border=\"0\">";.

} else {.

Echo "<img src=\"images/stock_instock.gif\" border=\"0\">";.

}.

?>.

Now I don't get any errors, displaying an image, but it doesn't matter what number on stock I have, it always displays the last part which is the : INSTOCK.GIF.

As an addition:.

When I use this code:.

<?php.

If ($prod_quantity < 1) {.

Echo "<img src=\"images/stock_limitedstock.gif\" border=\"0\">";.

} elseif (($prod_quantity > 0) && ($prod_quantity < 10)) {.

Echo "<img src=\"images/stock_limitedstock.gif\" border=\"0\">";.

} else {.

Echo "<img src=\"images/stock_instock.gif\" border=\"0\">";.

}.

?>.

It always displays the LIMITEDSTOCK.GIF.

[the difference is in the first line : <1].

Hope this clears up things even more to make the code work.

Acheron [or someone else].

Could you please compare your original code with my tweaked ones and check what I have done and iron out the flaws?.

Thanks.

This post has been edited by.

PVK.

: 02 July 2004, 11:13..

Comment #4

Well if you want it that way ....

<?php.

If ($prod_quantity < 10) {.

Echo "<img src=\"images/stock_limitedstock.gif\" border=\"0\">";.

} else {.

Echo "<img src=\"images/stock_instock.gif\" border=\"0\">";.

}.

?>..

Comment #5

You didn't show your db query.

Anyhow, substitute $your_query with your database query:.

<?php.

   $rows = 0;.

   $products_query = tep_db_query($your_query);.

     while ($products = tep_db_fetch_array($products_query)) {.

     $rows++;.

   $prod_quantity = tep_get_products_stock($products['products_id']);.

     if ($prod_quantity < 1) {.

     echo tep_image(DIR_WS_IMAGES'stock_soldout.gif', 'Sold out');.

   } elseif (($prod_quantity > 0) && ($prod_quantity < 10)) {.

     echo tep_image(DIR_WS_IMAGES'stock_limitedstock.gif', 'Limited Stock');.

   } else {.

     echo tep_image(DIR_WS_IMAGES'stock_onstock.gif', 'In Stock')";.

   }.

 }.

?>.

Matti..

Comment #6

What is wrong with:.

<?php.

Switch (tep_get_products_stock($products_id)) {.

Case "0":.

Print '<img src="images/stock_soldout.gif" border="0">';.

Break;.

Case "1":.

Case "2":.

Case "3":.

Case "4":.

Case "5":.

Case "6":.

Case "7":.

Case "8":.

Case "9":.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Default:.

Print '<img src="images/stock_onstock.gif" border="0">';.

Break;.

}.

?>.

Far more graceful, far more portable. Less overhead..

This post has been edited by.

Burt.

: 02 July 2004, 11:43..

Comment #7

Thanks everybody..

I have tried 'em all but I just keep on getting errors. [exceept the one where I had to place my own query, but since I really have no idea what I had to fill in there, I decided to test the latest idea , reworked it a bit and that one worked fine, so i'll just go for that one.

The code now is :.

<?php $prod_quantity = tep_get_products_stock($products_id);.

Switch ($prod_quantity) {.

Case 0:.

Print '<img src="images/stock_soldout.gif" border="0">';.

Break;.

Case 10:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Default:.

Print '<img src="images/stock_instock.gif" border="0">';.

Break;.

} ?>.

Thanks for trying to help a total NOSCRIPTER.

I learned some stuff along the way, I just have to figure out what it is exactly.

This post has been edited by.

PVK.

: 02 July 2004, 13:10..

Comment #8

With the latest code you posted, a quantity of 10 == limited stock, but a quantity of 5 == in stock..

I'm not sure that's the behaviour your require, is it ?

Comment #9

No you are right..

I also saw that when I posted it so I changed the 10 into 1.

That should do the trick am I correct?.

Thanks for all the help..

Comment #10

<?php $prod_quantity = tep_get_products_stock($products_id);.

Switch ($prod_quantity) {.

Case 0:.

Print '<img src="images/stock_soldout.gif" border="0">';.

Break;.

Case 1:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case 2:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case 3:.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case 4:.

Print '<img src="images/stock_instock.gif" border="0">';.

Break;.

Case 120:.

Print '<img src="images/stock_instock.gif" border="0">';.

Break;.

} ?>.

This is a piece of code from an existing and already running contribution, but I would like to tweak it a bit, but don't know how..

Hopefully someone can rewrite it a bit, because basically what I have to do now would be to make an entry for every step of the quantity available..

Which is not so bad if you only have 1 to 10 products, but if you have large amounts on stock [100dreds], this would create a HUGE column in the products info page ..

I don't know if this would make the iPage site or page slow ????.

But what I am thinking of is to make like 3 states from the above piece of code, which would have to be something like this :.

Case below 1 :.

Print '<img src="images/stock_soldout.gif" border="0">';.

Break;.

Case below 10 [but above 0] :.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

Break;.

Case above 10 :.

Print '<img src="images/stock_onstock.gif" border="0">';.

Break;.

I know the code I wrote above is aboslutely nonsense, but that is because I don't know jack about codes.

ANyone knows the solution?..

Comment #11

Try:.

<?php.

If ($prod_quantity < 1){?>.

Print '<img src="images/stock_soldout.gif" border="0">';.

<?php}.

Elseif (($prod_quantity > 0) && ($prod_quantity < 10){?>.

Print '<img src="images/stock_limitedstock.gif" border="0">';.

<?php}.

Else{?>.

Print '<img src="images/stock_onstock.gif" border="0">';.

<?php}?>.

This post has been edited by.

Yesudo.

: 01 July 2004, 23:36..

Comment #12


This question was taken from a support group/message board and re-posted here so others can learn from it.