Loversama Posted July 7, 2010 Share Posted July 7, 2010 Hey guys, thanks for looking at my topic first of all, I am having afew problems with a snippet of code. Its been coded to show certain colors behind a price depending on stock, and its also been coded to show things like (ASK) & (COU) ect when its defined in the database, What I wanted to do was add to that, I wanted it to say (ASK) when the stock is below a certain figure, and to say (in Stock) when its above a certain figure, I cannot understand fully how to do it. Not very good at PHP, only managed to get this far with the help of my PHP coder friend whos now away =[ If possilbe would anyone be able to help me out on this one? ?php if(empty($_SESSION['global_login_session'])){ echo '<td colspan="2"><a href="/contact-us/" class="call_button">Call</a><a href="/login/" class="login_button">Login</a></td>'; } else { // lets show them our ex prices if(empty($row['price']) || $row['instock']=='NO'){ echo '<td style="background:#F95151">N/A</td>'; } else { if($row['Stock']>=1){ $coco = '5BD0DF'; } else { if($row['oldunit']>=4){ $coco = '75E985'; } else { $coco = 'F9E351'; } } if($row['instock']=='COU'){ echo '<td style="background:#F95151">£'.$row['price'].' (COU)</td>'; } elseif($row['instock']=='ASK'){ echo '<td style="background:#F9E351">£'.$row['price'].' (ASK)</td>'; } elseif($row['instock']=='NEW'){ echo '<td style="background:#F95151">N/A (NEW)</td>'; } else { echo '<td style="background:#'.$coco.'">£'.$row['price'].'</td>'; } } // our new prices for the part if(empty($row['newprice']) || $row['instock']=='NO'){ echo '<td style="background:#F95151">N/A</td>'; } else { if($row['NewStock']>=1){ $coco = '5BD0DF'; } else { $coco = 'F9E351'; } echo '<td style="background:#'.$coco.'">£'.$row['newprice'].'</td>'; } } ?> Thanks in Advanced, Nathan. Link to comment https://forums.phpfreaks.com/topic/206998-small-problem/ Share on other sites More sharing options...
MadTechie Posted July 7, 2010 Share Posted July 7, 2010 Hi Loversama Your need to replace this code if($row['instock']=='COU'){ echo '<td style="background:#F95151">£'.$row['price'].' (COU)</td>'; } elseif($row['instock']=='ASK'){ echo '<td style="background:#F9E351">£'.$row['price'].' (ASK)</td>'; } elseif($row['instock']=='NEW'){ echo '<td style="background:#F95151">N/A (NEW)</td>'; } else { echo '<td style="background:#'.$coco.'">£'.$row['price'].'</td>'; } with this if($row['Stock'] > 111){ echo '<td style="background:#F95151">£'.$row['price'].' (in Stock)</td>'; } elseif($row['Stock'] < 110){ echo '<td style="background:#F9E351">£'.$row['price'].' (ASK)</td>'; } elseif($row['instock']=='NEW'){ echo '<td style="background:#F95151">N/A (NEW)</td>'; } else { echo '<td style="background:#'.$coco.'">£'.$row['price'].'</td>'; } Note: 111 is the "certain figure" for (in Stock) 110 is the "certain figure" for (ASK) Link to comment https://forums.phpfreaks.com/topic/206998-small-problem/#findComment-1082507 Share on other sites More sharing options...
Loversama Posted July 7, 2010 Author Share Posted July 7, 2010 Thanks for your help, I did get this message: Parse error: parse error, unexpected $ in /var/www/vhosts/httpdocs/results.php on line 402 Something I did? ;o Link to comment https://forums.phpfreaks.com/topic/206998-small-problem/#findComment-1082513 Share on other sites More sharing options...
MadTechie Posted July 7, 2010 Share Posted July 7, 2010 Can you post lines 400 to 404 Link to comment https://forums.phpfreaks.com/topic/206998-small-problem/#findComment-1082534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.