lauramarie Posted October 24, 2007 Share Posted October 24, 2007 $itemGroup = new ItemGroup($imhRegDetails); $item = isset($_POST['imhreg']) ? $itemGroup->item((int) $_POST['imhreg']) : null; $item2 = isset($_POST['recep']) ? $itemGroup->item((int) $_POST['recep']) : null; $totalCost = $item->getCost() + $item2->getCost(); ======================================================= <?=$item->getCost() > 0 ? $item->getName() : ''?> <?=$item->getCost() > 0 ? '$' . $item->getCost() : ''?> <?=$item2->getCost() > 0 ? $item2->getName() : ''? <?=$item2->getCost() > 0 ? '$' . $item2->getCost() :''?> ========================================================== I know that isset is supposed to go somewhere in the second set of code but I dont know where or how do to it. Can someone help me? Link to comment https://forums.phpfreaks.com/topic/74631-help/ Share on other sites More sharing options...
MadTechie Posted October 24, 2007 Share Posted October 24, 2007 telling us the "problem" may be an idea! Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377225 Share on other sites More sharing options...
lauramarie Posted October 24, 2007 Author Share Posted October 24, 2007 Basically, I need it to display 1 item if it is checked or both items if they are checked. Right now, If 1 is checked it displays it twice. Does that help? Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377231 Share on other sites More sharing options...
MadTechie Posted October 24, 2007 Share Posted October 24, 2007 you could try changing the null's to 0 ~OR~ <?=!is_null($item->getCost()) ? $item->getName() : ''?> <?=!is_null($item->getCost()) ? '$' . $item->getCost() : ''?> <?=!is_null($item2->getCost()) ? $item2->getName() : ''? <?=!is_null($item2->getCost()) ? '$' . $item2->getCost() :''?> Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377239 Share on other sites More sharing options...
lauramarie Posted October 24, 2007 Author Share Posted October 24, 2007 This is currently what my code looks like.. <?=($item->getCost() > 0) ? $item->getName() : ''?> <?=($item->getCost() > 0) ? '$' . $item->getCost() : ''?> <?=($item2->getCost() > 0) ? $item2->getName() : ''?> <?=($item2->getCost() > 0) ? '$' . $item2->getCost() :''?> When I use it I get this error... Fatal error: Call to a member function on a non-object in /home/content/T/A/I/TAIMH/html/confirm2-2.php on line 8 my code for line 8 and others is.... $itemGroup = new ItemGroup($imhRegDetails); $item = isset($_POST['imhreg']) ? $itemGroup->item((int) $_POST['imhreg']) : null; $item2 = isset($_POST['recep']) ? $itemGroup->item((int) $_POST['recep']) : null; $totalCost = $item->getCost() + $item2->getCost(); <======Line 8=======> $order = new PaypalOrder(array($item, $item2)); Does this help anyone anymore to help me figure this out? Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377251 Share on other sites More sharing options...
MadTechie Posted October 24, 2007 Share Posted October 24, 2007 Well your not using the class correctly.. the way your using it your $totalCost would have to be worked out like this $totalCost = $item + $item2; Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377271 Share on other sites More sharing options...
lauramarie Posted October 24, 2007 Author Share Posted October 24, 2007 I now get this error... Fatal error: Unsupported operand types in /home/content/T/A/I/TAIMH/html/confirm2-2.php on line 8 I dont mean to seem super stupid about this, but I'm new to the whole php script thingy. Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377280 Share on other sites More sharing options...
MadTechie Posted October 24, 2007 Share Posted October 24, 2007 where did you get the class from ? i assume theirs also a "setCost()" but without more details its going to be hit & miss Link to comment https://forums.phpfreaks.com/topic/74631-help/#findComment-377289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.