PHP - Spare Change Calculator
Hi! Need some help with a piece of code. New to this, so it is quite a pain in the ass! I need to make a code that shows the what spare change you should give back. so for example. when i put in 7 it should give back: 1 x 5 euro 1 x euro Which it does. but i have some trouble putting in the 1 euro's. for example when i put in 21 it gives back 2 x 10 euro Who can help me out? <?php function results($value) { if ($value >= 10) { echo floor($value / 10) . ' X 10 euro ' . PHP_EOL; $modulf = $value % 10; if ($modulf >= 5) { echo floor($modulf / 5) . ' X 5 euro ' . PHP_EOL; $modult = $modulf % 5; if ($modult >= 2) { echo floor($modult / 2) . ' X 2 euro ' . PHP_EOL; } } } else if ($value >= 5) { echo floor($value / 5) . ' X 5 euro ' . PHP_EOL; $modult = $value % 5; if ($modult >= 2) { echo floor($modult / 2) . ' X 2 euro ' . PHP_EOL; } } else if ($value >= 2) { echo floor($value / 2) . ' X 2 euro ' . PHP_EOL; } else if ($value >= 1) { echo floor($value / 1) . ' X 1 euro ' . PHP_EOL; } } if (count($argv) > 1) { $input = $argv[1]; if (!(is_numeric($input))) { echo 'Geen wisselgeld' . PHP_EOL; } else { $input = intval($argv[1]); if ($input !== 0) { results($input); } else { echo 'Geld wisselgeld' . PHP_EOL; } } } else { echo 'Geen wisselgeld' . PHP_EOL; }
Similar TutorialsThere's one that I've found...but I'm just struggling applying it to what I'm doing. The idea is to have x number of teams, all starting with 1000 Ranking points. If team A plays team B and wins 1-0, team A should increase by 30 points, and team B should decrease by 30 points? (I think.. ) Then to rank the teams based on their points. The main problem is, I'd like to use a form to edit the teams. I've got as far as a drop down menu to choose the teams, and then Home goals and Away goals. It will already define what is a win/draw/loss. The Calculator code is: <?php class elo_calculator { public function rating($S1,$S2,$R1,$R2) { if (empty($S1) OR empty($S2) OR empty($R1) OR empty($R2)) return null; if ($S1!=$S2) { if ($S1>$S2) { $E=120-round(1/(1+pow(10,(($R2-$R1)/400)))*120); $R['R3']=$R1+$E; $R['R4']=$R2-$E; } else { $E=120-round(1/(1+pow(10,(($R1-$R2)/400)))*120); $R['R3']=$R1-$E; $R['R4']=$R2+$E; }} else { if ($R1==$R2) { $R['R3']=$R1; $R['R4']=$R2; } else { if($R1>$R2) { $E=(120-round(1/(1+pow(10,(($R1-$R2)/400)))*120))-(120-round(1/(1+pow(10,(($R2-$R1)/400)))*120)); $R['R3']=$R1-$E; $R['R4']=$R2+$E; } else { $E=(120-round(1/(1+pow(10,(($R2-$R1)/400)))*120))-(120-round(1/(1+pow(10,(($R1-$R2)/400)))*120)); $R['R3']=$R1+$E; $R['R4']=$R2-$E; }}} $R['S1']=$S1; $R['S2']=$S2; $R['R1']=$R1; $R['R2']=$R2; $R['P1']=((($R['R3']-$R['R1'])>0)?"+".($R['R3']-$R['R1']):($R['R3']-$R['R1'])); $R['P2']=((($R['R4']-$R['R2'])>0)?"+".($R['R4']-$R['R2']):($R['R4']-$R['R2'])); return $R; }} ?> Im after a little bit of help with two things in my code. www.1pw.co.uk/demo2.php 1) getting an image to appear opposed to just the filename. where and how in my code should i put <img src="filename" /> in the img column of mysql database i am just listing filenames. should i wrap these in the html above instead? 2) how can i get my calculator to behave? i get the correct tally when checking out (using order.php), but as you will see from the link provided the calculator does not work properly, in demo2.php -- addtocart2.php -- Code: [Select] <?php define('INCLUDE_CHECK',1); require "../connect2.php"; if(!$_POST['img']) die("There is no such product!"); $img=mysql_real_escape_string(end(explode('/',$_POST['img']))); $row=mysql_fetch_assoc(mysql_query("SELECT * FROM internet_shop WHERE img='".$img."'")); $jsonArr = array('img' => $row['img'], 'status' => 1, 'id' => $row['id'], 'price' => $row['price'], 'txt' => ' <table width="100%" id="table_'.$row['id'].'"> <tr> <td width="40%">'.$row['img'].'</td> <td width="20%">'.$row['name'].'</td> <td width="10%">$'.$row['price'].'</td> <td width="15%"> <select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option></slect> </td> <td width="15%"><a href="#" onclick="remove('.$row['id'].');return false;" class="remove">remove</a></td> </tr> </table>'); echo json_encode($jsonArr); ?> --- demo2.php --- Code: [Select] <?php define('INCLUDE_CHECK',1); require "connect2.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>shop</title> <link rel="stylesheet" type="text/css" href="demo.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script type="text/javascript" src="jquery.ui.main.js"></script> <!--[if lt IE 7]> <style type="text/css"> .pngfix { behavior: url(pngfix/iepngfix.htc);} .tooltip{width:200px;}; </style> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <script type="text/javascript" src="simpletip/jquery.simpletip-1.3.1.pack.js"></script> <script type="text/javascript" src="script2.js"></script> </head> <body> <div id="main-container"> <div class="tutorialzine"> <h1>Shopping cart</h1> <h3>The best products at the best prices</h3> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Products</span> </span> <div class="content-area"> <div class="content drag-desired"> <?php $result = mysql_query("SELECT * FROM internet_shop"); while($row=mysql_fetch_assoc($result)) { echo '<div class="product"><a href="#" class="item"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></a></div>'; } ?> <div class="clear"></div> </div> </div> <div class="bottom-container-border"> </div> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Shopping Cart</span> </span> <div class="content-area"> <div class="content drop-here"> <div id="cart-icon"> <img src="img/Shoppingcart_128x128.png" alt="shopping cart" class="pngfix" width="128" height="128" /> <img src="img/ajax_load_2.gif" alt="loading.." id="ajax-loader" width="16" height="16" /> </div> <form name="checkoutForm" method="post" action="order.php"> <div id="item-list"> </div> </form> <div class="clear"></div> <div id="total"></div> <div class="clear"></div> <a href="" onclick="document.forms.checkoutForm.submit(); return false;" class="button">Checkout</a> </div> </div> <div class="bottom-container-border"> </div> </div> </div> <div class="bowlpic"> </div> </body> </html> -- script2.js -- Code: [Select] var purchased=new Array(); var totalprice=0; $(document).ready(function(){ $('.product').simpletip({ offset:[40,0], content:'<img src="img/ajax_load.gif" alt="loading" style="margin:10px;" />', onShow: function(){ var param = this.getParent().find('img').attr('src'); if($.browser.msie && $.browser.version=='6.0') { param = this.getParent().find('img').attr('style').match(/src=\"([^\"]+)\"/); param = param[1]; } this.load('ajax/tips.php',{img:param}); } }); $(".product img").draggable({ containment: 'document', opacity: 0.6, revert: 'invalid', helper: 'clone', zIndex: 100 }); $("div.content.drop-here").droppable({ drop: function(e, ui) { var param = $(ui.draggable).attr('src'); if($.browser.msie && $.browser.version=='6.0') { param = $(ui.draggable).attr('style').match(/src=\"([^\"]+)\"/); param = param[1]; } addlist(param); } }); }); function addlist(param) { $.ajax({ type: "POST", url: "ajax/addtocart2.php", data: 'img='+encodeURIComponent(param), dataType: 'json', beforeSend: function(x){$('#ajax-loader').css('visibility','visible');}, success: function(msg){ $('#ajax-loader').css('visibility','hidden'); if(parseInt(msg.status)!=1) { return false; } else { var check=false; var cnt = false; for(var i=0; i<purchased.length;i++) { if(purchased[i].id==msg.id) { check=true; cnt=purchased[i].cnt; break; } } if(!cnt) $('#item-list').append(msg.txt); if(!check) { purchased.push({id:msg.id,cnt:1,price:msg.price}); } else { if(cnt>=3) return false; purchased[i].cnt++; $('#'+msg.id+'_cnt').val(purchased[i].cnt); } totalprice+=msg.price; update_total(); } $('.tooltip').hide(); } }); } function findpos(id) { for(var i=0; i<purchased.length;i++) { if(purchased[i].id==id) return i; } return false; } function remove(id) { var i=findpos(id); totalprice-=purchased[i].price*purchased[i].cnt; purchased[i].cnt = 0; $('#table_'+id).remove(); update_total(); } function change(id) { var i=findpos(id); totalprice+=(parseInt($('#'+id+'_cnt').val())-purchased[i].cnt)*purchased[i].price; purchased[i].cnt=parseInt($('#'+id+'_cnt').val()); update_total(); } function update_total() { if(totalprice) { $('#total').html('total: $'+totalprice); $('a.button').css('display','block'); } else { $('#total').html(''); $('a.button').hide(); } } -- order2.php -- Code: [Select] <?php define('INCLUDE_CHECK',1); require "connect2.php"; if(!$_POST) { if($_SERVER['HTTP_REFERER']) header('Location : '.$_SERVER['HTTP_REFERER']); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="demo.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <script type="text/javascript" src="simpletip/jquery.simpletip-1.3.1.pack.js.txt"></script> <script type="text/javascript" src="script2.js"></script> </head> <body> <div id="main-container"> <div class="container"> <span class="top-label"> <span class="label-txt">Your order</span> </span> <div class="content-area"> <div class="content"> <?php $cnt = array(); $products = array(); foreach($_POST as $key=>$value) { $key=(int)str_replace('_cnt','',$key); $products[]=$key; $cnt[$key]=$value; } $result = mysql_query("SELECT * FROM internet_shop WHERE id IN(".join($products,',').")"); if(!mysql_num_rows($result)) { echo '<h1>There was an error with your order!</h1>'; } else { echo '<h1>You ordered:</h1>'; while($row=mysql_fetch_assoc($result)) { echo '<h2>'.$cnt[$row['id']].' x '.$row['name'].'</h2>'; $total+=$cnt[$row['id']]*$row['price']; } echo '<h1>Total: $'.$total.'</h1>'; } ?> <div class="clear"></div> </div> </div> <div class="bottom-container-border"> </div> </div> </div> </body> </html> is there a way for php to calculate age based on birthdate with mm/dd/yyyy format? or do I need some converter? if so, how? Hi there, I'm trying to create a land transfer tax calculator. The formula is to be as follows Up to and including $55,000.00 0.5% plus $55,000.01 to $400,000.00 1.0% plus Over $400,000.00 2.0% FOR EXAMPLE: A home with a consideration value of $500,000.01 MLTT Rate Calculation 0 to $55,000.00 55,000.00 x 0.005 = $275.00 $55,000.01 to $400,000.00 $344,999.99 x 0.01= $3,450.00 $400,000.01 to $500,000.00 $99,999.99 x 0.02= $2,000.00 Total MLTT= $5,725.00 what I have so far is Code: [Select] <form method="GET" name="tax" action="http://www.abc.com/what-can-i-afford/"> <input type="hidden" name="comp_form" value="1"> <table cellpadding="2" cellspacing="0" border="0" width="100%" align="center"> <tr valign="top" bgcolor="#eeeeee"> <td align="right" width="150px">Home Cost</td> <td><input type="text" size="10" name="home_cost" value="<?php echo $home_cost; ?>"> (In Dollars)</td> </tr> <tr><td> </td></tr> <tr><td><input type="submit" value="Calculate"><br> <?php if ($comp_form) { print("<a href=\"" . $_SERVER['PHP_SELF'] . "\">Start Over</a><br>"); } ?><br></td> </tr> </table> <?php /* -----------------------------------------------*/ /* Affordability Calc */ /* Set Form DEFAULT values */ $home_cost = 0; /* Set the USER INPUT values */ if (isset($_REQUEST['comp_form'])) { $home_cost = $_REQUEST['home_cost']; if ($home_cost >= 55000) { $MLTT = 55000 * 0.005; if ( ($home_cost >= 55000.01) && ($home_cost <= 400000.01) ) { $MLTT = $MLTT + (($home_cost - 55000)*0.01); if ( ($home_cost >= 400000.01) && ($home_cost <= 500000) ) { $MLTT = $MLTT + (($home_cost - 400000.01)*0.02); } } echo $MLTT; } ?> <h2>MLTT is:<?php $MLTT ?></h2> <?php } ?> I'm only getting 275??? Please help as I'm unsure how to break up the home amount and perform each calculation hi ! I'm not a PHP master, now i'd like to program an online calculator on my website. it's not the classical calculator with + / - / x / ln etc... but a specific, simple though, calculator. I'd like even to be able to export the results of the calculations into a xls or csv file (that would be the next step) Is that possible to do that with PHP ? or i should look more at javascript or java (dont like that idea) or flash etc... Thanks for your replies ! Website: http://novacms.vacau.com/index.php I'm trying to make a calculator for this game I play, it's fully developed, but with one bug. It doesn't do the math right. $goal = The amount of EXP (Experience Points) someone wants to get $exp = The amount of EXP they currently have $npcs_exp["exp"] = The amount of EXP the monster has But, when they enter in the information, the calculation is all screwed up. When I do it, it seems to give me the same number EACH time. The part where the calculation "goes down". Remember, I'm trying to see how many times you need to kill a NPC to achieve your goal. //math $npc_exp_extract = mysql_query("SELECT exp FROM npcs WHERE name='$npc'"); $npcs_exp = mysql_fetch_assoc($npc_exp_extract); $amount = $goal / $npcs_exp["exp"]; Full code: <?php $exp = $_POST["exp"]; $npc = $_POST["npc"]; $goal = $_POST["goal"]; mysql_connect("removed", "removed", "removed"); mysql_select_db("a2248602_npcs"); if(!$goal || !$npc || !$exp) { echo "<center><form action='index.php' method='POST'>GOAL: <input type='text' name='goal'> Current XP: <input type='text' name='exp'>"; echo "NPC: <select name='npc'>"; $npc_extract = mysql_query("SELECT * FROM npcs"); while($npcs = mysql_fetch_assoc($npc_extract)) { echo "<option name='". $npcs['name'] ."'>". $npcs['name'] ."</option>"; } echo "</select> <input type='submit'></form></center>"; } else { //math $npc_exp_extract = mysql_query("SELECT exp FROM npcs WHERE name='$npc'"); $npcs_exp = mysql_fetch_assoc($npc_exp_extract); $amount = $goal / $npcs_exp["exp"]; if($amount=="1") { echo "You will need to kill a <b/>". $npc ."</b> <b>". $amount ."</b> more time. You earn ". $npcs_exp["exp"] ." XP for each kill from this NPC. | <a href='index.php'>Do another</a><br/><br/>"; } else { echo "You will need to kill a <b/>". $npc ."</b> <b>". $amount ."</b> more times. You earn ". $npcs_exp["exp"] ." XP for each kill from this NPC. | <a href='index.php'>Do another</a><br/><br/>"; } } echo "<center>Made by Zaros from <a href='creation-x.net'>Creation-X</a></center>"; ?> Mod edit: DB credentials removed. Hey there, I recently started working on a PHP calculator, I tryed testing it out and the script is not executing... *NOTE* I found the error, I forgot to assign values to the options, all is good now Code: [Select] <?php /* Script Created by: Far Cry Started: August 20th, 2010 10:51 PM PST Completed */ $title = "Calculator"; $form = "<form action='calculator.php' method='POST'> <table> <tr> <td><input name='firstnumber' type='text'></td> </tr> <tr> <td><input name='secondnumber' type='text'></td> </tr> <tr> <td><select name='operation'> <option name='multiply'>*</option> </select></td> </tr> <tr> <td><input name='submitbtn' type='submit' value='Calculate!'></td> </tr> </table> </form>"; if ($_POST['submitbtn']){ $first = ($_POST['firstnumber']); $last = ($_POST['secondnumber']); $operation = ($_POST['operation']); } if ($operation == 'multiply'){ echo"The answer is " . $first * $last . $form; } echo $form; ?> Thanks in advance. First of all hi everyone, this is my first post as you can see. And i have my first task in PHP, now i warn you i have no experience or know-how whatsover in PHP so please bear with me. My first task is to extend some PHP code to add some functions. the code weve been given already is capable of mutiplication of two variables x and y. Here it is anyway. 1. View the code and copy/paste it into an editor and save it to your own workspace. 2. Extend the script to perform the four basic arithmetic functions : +, -, *, / and return a result. 3. Extend the script again to move the calculations into a function and make use of this function. Code: [Select] <?php /* ====================================================== PHP Calculator example using "sticky" form (Version 1) ====================================================== Author : P Chatterjee (adopted from an original example written by C J Wallace) Purpose : To multiply 2 numbers passed from a HTML form and display the result. input: x, y : numbers calc : Calculate button pressed Date: 15 Oct 2007 */ // grab the form values from $_HTTP_POST_VARS hash extract($_GET); // first compute the output, but only if data has been input if(isset($calc)) { // $calc exists as a variable $prod = $x * $y; } else { // set defaults $x=0; $y=0; $prod=0; } ?> <html> <head> <title>PHP Calculator Example</title> </head> <body> <h3>PHP Calculator (Version 1)</h3> <p>Multiply two numbers and output the result</p> <form method="get" action="<?php print $_SERVER['PHP_SELF']; ?>"> x = <input type="text" name="x" size="5" value="<?php print $x; ?>"/> y = <input type="text" name="y" size="5" value="<?php print $y; ?>"/> <input type="submit" name="calc" value="Calculate"/> <input type="reset" name="clear" value="Clear"/> </form> <!-- print the result --> <?php if(isset($calc)) { print "<p>x * y = $prod</p>"; } ?> </body> </html> Firstly how do i run this code, i have Xamp installed if thats any good? Secondly, do i need two seperate files. i.e. calculator.php for the php code and calculator.html for the form? Thirdly i have no idea how to implement the divide, add and subtract functions. should i do a drop down menu where the user should select what operator they want? or is it more simple than that. Any help greatly appreciated. Please let me know if this post is okay. Hello People. I would like to build a small calculator in php for my website. Basically what it does is give a form to the user that looks like this The formula is as follows. number_from_box1 * number_from_box2 =result1 then take result1 *52 =result2 now take 60,000 /result2 =result3 Take result3 and make it a number with only 2 decimal places =result4 Then display the result on the form like this Your warranty would be "result4" years I know that there are some really good coders on here. Please could one of you talented people tell me what is the php to do the above on my site? Hi Guys I need a PHP function to which I pass two postcodes and it works out the road distance, I dont mind using google or any other API I have managed to fing JS ways and php functions using crow route but I really really need a traffic distance in PHP Please advice, Help Thank you Need to change the value in an XML string tried the following but no luck, any suggestions?
$_xml_string = '<Order> <EmbeddedDoc DocumentName="TestDoc" DocumentFormat="PDF">jdsahfdhflhfsdlfhdslhsdflsdfhflkdslkfsdhkfhskldhkl</EmbeddedDoc> <EmbeddedDoc DocumentName="TestDoc1" DocumentFormat="PDF">jdsahfdhflhfsdlfhdslhsdflsdfhflkdslkfsdhkfhskldhkl</EmbeddedDoc> </Order>'; foreach($_xml_string->Order->EmbeddedDoc as $document) { $document ='##FILE_CONTENT##'; } <?php require_once('config/config.php'); include ("files/viator/api.php"); $page = new PhpCode(); $current_page = $page->curPageURL(); $_SESSION['last_page'] = $current_page ; function seoUrl($string) { //Lower case everything $string = strtolower($string); //Make alphanumeric (removes all other characters) $string = preg_replace("/[^a-z0-9_\s-]/", "", $string); //Clean up multiple dashes or whitespaces $string = preg_replace("/[\s-]+/", " ", $string); //Convert whitespaces and underscore to dash $string = preg_replace("/[\s_]/", "-", $string); return $string; } if(isset($_GET['submit']) && !empty($_GET['submit'])) { $lookupId = $_GET['lookupId']; $dest_code = $_GET['dest_code']; $currency_code = $_GET['currency_code']; $sortOrder = $_GET['sortOrder']; $catId = $_GET['catId']; $subcategoryId = $_GET['subcategoryId']; $country_name = $_GET['country_name']; $state_name = $_GET['state_name']; $country_dest_id= $_GET['country_dest_id']; $check_in = $_GET['check_in']; $check_out = $_GET['check_out']; if($dest_code =='' && $country_dest_id != '') { $dest_code = $country_dest_id; } } else if(isset($_GET['search_submit']) && !empty($_GET['search_submit'])){ $dest_code = $_GET['dest_code']; $currency_code = $_GET['currency_code']; $sortOrder = $_GET['sortOrder']; $catId = $_GET['catId']; $subcategoryId = $_GET['subcategoryId']; $country_name = $_GET['country_name']; $state_name = $_GET['state_name']; $country_dest_id= $_GET['country_dest_id']; $check_in = $_GET['check_in']; $check_out = $_GET['check_out']; $lookupId = $_GET['lookupId']; if($dest_code =='' && $country_dest_id != '') { $dest_code = $country_dest_id; } } else { $lookupId = $_GET['lookupId']; $dest_code = $_GET['dest_code']; $currency_code = $_GET['currency_code']; $sortOrder = $_GET['sortOrder']; $catId = $_GET['catId']; $subcategoryId = $_GET['subcategoryId']; $country_name = $_GET['country_name']; $state_name = $_GET['state_name']; $country_dest_id= $_GET['country_dest_id']; $check_in = $_GET['check_in']; $check_out = $_GET['check_out']; if($dest_code =='' && $country_dest_id != '') { $dest_code = $country_dest_id; } } $getdataarr = getAdventureSearch($dest_code,$currency_code,$sortOrder,$check_in,$check_out); $adventure_data_arr = $getdataarr['data']; $image = '' ; $part = new Body(); $title = "Things to do in "; if($state_name !="") { $title .= $state_name.' ' ;} if ($country_name=="United States of America") { $title .= 'USA ' ; $breadcrumb = 'USA';} elseif ($country_name=="United Arab Emirates") { $title .= 'UAE ' ; $breadcrumb = 'UAE'; } elseif ($country_name!="") { $title .= $country_name; } $title .= " | Compare & Choose"; $meta = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="' .$state_name. ' Attractions & Things to do in ' .$country_name. '. Find your adventure in ' .$country_name. ' Today." /><link rel="canonical" href="//www.compareandchoose.com.au/adventure_list"/> <!-- MICROFORMATS FOR GPLUS --> <link href="https://plus.google.com/+CompareandchooseAuTravel/posts" rel="publisher" /> <meta itemprop="name" content="' .$title. '"> <meta itemprop="description" content="' .$state_name. ' Attractions & Things to do in ' .$country_name. '. Find your adventure in ' .$country_name. ' Today."> <meta property="og:locale" content="en_US" /> <meta property="og:type" content="website" /> <meta property="og:title" content="' .$title. '" /> <meta property="og:description" content="' .$state_name. ' Attractions & Things to do in ' .$country_name. '. Find your adventure in ' .$country_name. ' Today." /> <meta property="og:url" content="http://www.compareandchoose.com.au/" /> <meta property="og:site_name" content="Compare and Choose" /> <meta property="article:publisher" content="https://www.facebook.com/compareandchoose" /> <meta property="fb:app_id" content="1386609318277530" /> <meta property="og:image" content="http://www.compareandchoose.com.au/images/Compare-and-Choose-logo.png" /> <meta property="og:image:width" content="313" /> <meta property="og:image:height" content="75" />'; $head = $part->getHead($title,$meta); $header = $part->getHeader('Adventure'); $footer = $part->getFooter(); echo $head; echo $header; ?> <script> function sort() { $('.overlay_wrap').fadeIn(); $('.loader_hotel_page').fadeIn(); } </script> <div class="overlay_wrap" style="display: none;"></div> <div class="loader_hotel_page" style="display: none;"><img src="<?php echo SITE_URL; ?>images/search-loader.gif" alt="searching-records"/></div> <!-----Adventure Listing-----> <div class="container"> <div class="listing"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3"> <div class="refine-search travel"> <?php require_once('files/keyword_search.php'); ?> <div class="block"> <div class="block-content"> <div class="block-title">Top Selling Tours & Activities</div> <div class="block-inner"> <div class="top-rated-pic"> <!--<img src="images/small-pic1.png" alt="" />--> </div> <div class="top-topics-sec"> <?php $getcatdataarr = getCategoryDestination($dest_code); $category_arr = $getcatdataarr['data']; $i=1; if($category_arr !="") { foreach ($category_arr as $categoryList) { if($catId == $categoryList['id']) { $image = $categoryList['thumbnailURL']; $groupName = $categoryList['groupName']; ?> <p onclick="sort()"> <strong><?php echo $i;?>.</strong><a href="adventure_list.php?currency_code=<?php echo $currency_code; ?>&dest_code=<?php echo $dest_code;?>&sortOrder=<?php echo $sortOrder;?>&catId=<?php echo $categoryList['id'];?>&country_name=<?php echo $country_name;?>&state_name=<?php echo $state_name;?>&country_dest_id=<?php echo $country_dest_id; ?>&lookupId=<?php echo $lookupId;?>&check_in=<?php echo $check_in;?>&check_out=<?php echo $check_out;?>"><?php echo stripslashes($categoryList['groupName']);?></a> <?php $subcategories_arr = $categoryList['subcategories']; foreach($subcategories_arr as $subcatList) { echo '<br>'; ?> <a href="adventure_list.php?currency_code=<?php echo $currency_code; ?>&dest_code=<?php echo $dest_code;?>&sortOrder=<?php echo $sortOrder;?>&catId=<?php echo $categoryList['id'];?>&subcategoryId=<?php echo $subcatList['subcategoryId'];?>&country_name=<?php echo $country_name;?>&state_name=<?php echo $state_name;?>&country_dest_id=<?php echo $country_dest_id; ?>&lookupId=<?php echo $lookupId;?>&check_in=<?php echo $check_in;?>&check_out=<?php echo $check_out;?>"><?php echo stripslashes($subcatList['subcategoryName']); ?></a> <?php } ?> </p> <?php } else{ ?> <p onclick="sort()"><strong><?php echo $i;?>.</strong><a href="adventure_list.php?currency_code=<?php echo $currency_code; ?>&dest_code=<?php echo $dest_code;?>&sortOrder=<?php echo $sortOrder;?>&catId=<?php echo $categoryList['id'];?>&country_name=<?php echo $country_name;?>&state_name=<?php echo $state_name;?>&country_dest_id=<?php echo $country_dest_id; ?>&lookupId=<?php echo $lookupId;?>&check_in=<?php echo $check_in;?>&check_out=<?php echo $check_out;?>"><?php echo stripslashes($categoryList['groupName']);?></a></p> <?php }$i++;} } ?> </div></div></div></div></div></div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-main"> <div class="row"> <?php if($image !='') { //$image = 'images/travel-pic.png'; ?> <div class="col-xs-12 col-md-4 col-lg-4"> <!--<img src="<?php echo $image;?>" alt="" />--> </div> <?php } ?> <div class="col-xs-12"> <h1>Things to do in <?php echo stripslashes($country_name);?></h1> <?php if($state_name == '') { $search_name = $country_name; } else{ $search_name = $state_name; } ?> <p>Compare and choose things to do in <?php echo stripslashes($search_name);?></p> <a href="#"><?php echo strtoupper(stripslashes($search_name));?> >></a> <?php if($groupName != '') { echo '<p>'.$groupName.'</p>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET"> <div class="filtering"> <select onchange="this.form.submit();" name="sortOrder"> <option value="TOP_SELLERS" <?php if($sortOrder == 'TOP_SELLERS'){echo 'selected';}?>>Most Popular</option> <option value="REVIEW_AVG_RATING_D" <?php if($sortOrder == 'REVIEW_AVG_RATING_D'){echo 'selected';}?>>Top Rated</option> <option value="PRICE_FROM_A" <?php if($sortOrder == 'PRICE_FROM_A'){echo 'selected';}?>>Price(Low - High)</option> <option value="PRICE_FROM_D" <?php if($sortOrder == 'PRICE_FROM_D'){echo 'selected';}?>>Price(High - Low)</option> </select> <input type="hidden" name="currency_code" value="<?php echo $currency_code;?>" id="currency_code"> <input type="hidden" name="lookupId" value="<?php echo $lookupId;?>" id="lookupId"> <input type="hidden" name="dest_code" value="<?php echo $dest_code;?>" id="dest_code"> <input type="hidden" name="catId" value="<?php echo $catId;?>" id="catId"> <input type="hidden" name="subcategoryId" value="<?php echo $subcategoryId;?>" id="subcategoryId"> <input type="hidden" name="country_name" value="<?php echo $country_name; ?>" id="country_name" > <input type="hidden" name="state_name" value="<?php echo $state_name;?>" id="state_name"> <input type="hidden" name="country_dest_id" value="<?php echo $country_dest_id;?>" id="country_dest_id"> </div> </form> </div><div class="c1"></div></div></div> <?php if($adventure_data_arr != ""){ foreach($adventure_data_arr as $adventureList) { $url = seoUrl($adventureList['title']); if($catId == '') { ?> <div class="travel-list-sec"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3 spacal-img"> <?php if($adventureList['specialOfferAvailable'] == 1) {?> <div class="spacal-tag"> <img src="images/specila-tag.png" alt="" /> </div> <?php } ?> <img src="<?php echo $adventureList['thumbnailHiResURL'];?>" alt="" width="166" height="160" /> </div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-det"> <h2 style="text-transform: uppercase; font: 400 15px 'Open Sans', sans-serif; text-decoration: none;"><a style="color: rgb(103, 191, 54);" href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>&lookupId=<?php echo $lookupId;?>&dest_code=<?php echo $dest_code; ?>"><?php echo stripslashes($adventureList['title']);?></a></h2> <p><?php echo stripslashes($adventureList['shortDescription']);?></p> <div class="rating-box"> <div class="ratings"> <?php $rate = $adventureList['rating']; $f= floor($rate); $c = ceil($rate); $cnt = 0; if($rate!="" && $rate!=0) { for($in = 1; $in<=$rate ;$in++) { $cnt++; ?> <img src="images/rating_full.png"> <?php } if($f != $c) { $cnt++; ?> <img src="images/rating_half.png"> <?php } } if($cnt<5) { while($cnt<5) { $cnt++; ?> <img src="images/rating_blank.png"> <?php } } ?> <!--<span class="stars"><?php echo $adventureList['rating']; ?></span>--> </div> <div class="rating-txt"> based on <?php echo $adventureList['reviewCount']; ?> reviews </div> <div class="c1"></div> </div> <div class="price-box"><a href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>&lookupId=<?php echo $lookupId;?>&dest_code=<?php echo $dest_code; ?>"> <span style="float: right; margin-right: 1%; padding: 6px 20px; color: white; background-color: rgb(108, 191, 61); text-align: center; font-size:16px; font-weight:400; ">See Details →</span></a> <span class="new_price">Duration :<?php echo stripslashes($adventureList['duration']);?></span><br /> <span class="new_price">From <?php echo stripslashes($adventureList['currencyCode']);?> <?php echo stripslashes($adventureList['priceFormatted']);?></span> <?php if($adventureList['specialOfferAvailable'] == 1) { ?> <div class="original"> <p>Original Price : <?php echo stripslashes($adventureList['rrpformatted']);?></p> </div> <div class="save-price"> <p>Saving Amount : <?php echo stripslashes($adventureList['savingAmountFormated']);?></p> </div> <?php } ?> </div></div></div><div class="c1"></div></div></div> <?php } else { if($subcategoryId == '') { $catgory_arr = $adventureList['catIds']; if(in_array($catId, $catgory_arr)) { ?> <div class="travel-list-sec"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3"> <img src="<?php echo $adventureList['thumbnailHiResURL'];?>" alt="" width="166" height="160" /> </div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-det"> <h1><a href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>"><?php echo stripslashes($adventureList['title']);?></a></h1> <p><?php echo stripslashes($adventureList['shortDescription']);?></p> <div class="rating-box"> <span class="stars"><?php echo $adventureList['rating']; ?></span> <div class="rating-txt"> based on <?php echo $adventureList['reviewCount']; ?> reviews </div> <div class="c1"></div> </div> <div class="price-box"> <div class="price">Duration :<?php echo stripslashes($adventureList['duration']);?></div> <div class="price">From <?php echo stripslashes($adventureList['currencyCode']);?> <?php echo stripslashes($adventureList['priceFormatted']);?></div> <?php if($adventureList['specialOfferAvailable'] == 1) { ?> <h3>Special Offer </h3> <p>Original Price : <?php echo stripslashes($adventureList['rrpformatted']);?></p> <p>Saving Amount : <?php echo stripslashes($adventureList['savingAmountFormated']);?></p> <?php } ?> </div></div></div><div class="c1"></div></div></div> <?php } } else{ $sub_catgory_arr = $adventureList['subCatIds']; if(in_array($subcategoryId, $sub_catgory_arr)) { ?> <div class="travel-list-sec"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3"> <img src="<?php echo $adventureList['thumbnailHiResURL'];?>" alt="" width="166" height="160" /> </div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-det"> <h1><a href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>"><?php echo stripslashes($adventureList['title']);?></a></h1> <p><?php echo stripslashes($adventureList['shortDescription']);?></p> <div class="rating-box"> <span class="stars"><?php echo $adventureList['rating']; ?></span> <div class="rating-txt"> based on <?php echo $adventureList['reviewCount']; ?> reviews </div> <div class="c1"></div> </div> <div class="price-box"> <div class="price">Duration :<?php echo stripslashes($adventureList['duration']);?></div> <div class="price">From <?php echo stripslashes($adventureList['currencyCode']);?> <?php echo stripslashes($adventureList['priceFormatted']);?></div> <?php if($adventureList['specialOfferAvailable'] == 1) { ?> <h3>Special Offer </h3> <p>Original Price : <?php echo stripslashes($adventureList['rrpformatted']);?></p> <p>Saving Amount : <?php echo stripslashes($adventureList['savingAmountFormated']);?></p> <?php } ?> </div></div></div><div class="c1"></div></div></div> <?php } } } } } ?> </div><div class="breadcrumb-new"> <ul> <li><div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a href="<?php echo SITE_URL;?>" itemprop="url"><span itemprop="title">Home</span></a><span>></span> </div></li> <li><strong>Adventures & Activities in <?php echo $state_name. ',' .$country_name; ?></strong></li> </ul> </div><div class="c1"></div></div></div></div> <?php echo $footer ;?> </body> </html>Hi All I am trying to change my website from http to https and I have ran into a problem with one of the scripts producing a none secure http problem Basically when I check this it shows a none secure error ERROR insecure url = http://cache.graphic...m/etcetcetc.jpg which needs to be https://cache.graphi...m/etcetcetc.jpg I thinks it is something to do with the array $adventureList array on line 285(not exactly sure, as I didn't write the code and I am not an expert) So my question is how do I change this to https url please find attached my page code thanks in advance all Alan Hi all I'm new to PHP so i might ask easy stuff Here is my Scenario I click a button .. this work fine But in the php code that runs after the button is clicked i need to change the Website uri (link) to something like this after button postback index?name=value How am i gonna do this . I tried header function but it did not work well Any suggestion please Sir, i know that we can change the user agent via cURL. i want to know is possible to change ip ? Can someone tell me why this code will not work? It's supposed to update the quantity in a shopping cart by taking the user input and changing the value of the array. I can add items by clicking the 'add to cart' button, but as you know that only works one at a time. Once you make a selection you have the opportunity to go to the cart and modify the quantity by entering in a numeric value; so instead of clicking 10 times you can just type 1, 0 to get to 10. Is there any other info I can provide to convey what I'm trying to do? I'm new to php so I don't know why it's not working, this looks right according to php.net but something is wrong. if(isset($_POST['submit'])) { foreach($_POST['quantity'] as $key => $value) { if($value==0) { unset($_SESSION['cart'][$key]); }else{ $_SESSION['cart']['$key']['quantity']=$value; } } } errors below: Invalid argument supplied for foreach() illegal string offset 'cart' Edited by somerandom, 22 October 2014 - 06:04 PM. Hi,
I'm having the following problem. I want to change the row color depending on the value of a record.
i made three different td class in the style.
Then i check the value of the record "TOEGEZEGD" and connect this to $NewClass,
The i try to change the color of the background.
$NewClass takes the value i want (check by display echo $NewClass)
But the background of the row doesn't change, i tried different methodes:
<td class = "$NewClass">'.$row['TOEGEZEGD'].'</td> <td class = \"$New$Class\">'.$row['VORM'].'</td> <td><DIV CLASS="$NewClass">'.$row['PAKKET'].'</DIV></td> But non of them work please help, it's driving my crazy <?php // checking for started session function is_session_started() { if ( php_sapi_name() !== 'cli' ) { if ( version_compare(phpversion(), '5.4.0', '>=') ) { return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; } else { return session_id() === '' ? FALSE : TRUE; } } return FALSE; } if ( is_session_started() === FALSE ) session_start(); if(isset($_SESSION ['ingelogd']) AND $_SESSION['ingelogd'] == 1) {} else { header("location:index.php"); exit; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>**********</title> <meta name="" content=""> </head> <body> <style> textarea, input, button, a, td, span{ font-family: "Trebuchet MS", Helvetica, sans-serif; } td{ color: blue; width: 100px; background-color: #ceffce; height: 50px; text-align: center; } td.JA{ color: red; width: 100px; background-color: #00ee00; height: 50px; text-align: left; } .JA{ color: red; width: 100px; background-color: #00ee00; height: 50px; text-align: left; } td.NEE{ color: green; width: 100px; background-color: #ff0000; height: 50px; text-align: left; } td.MISSCHIEN{ color: orange; width: 100px; background-color: #f07700; height: 50px; text-align: left; } td.op{ color: black; width: 450px; background-color: #ceDDce!important; height: 50px; text-align: left; } th{ color: black; width: 40px; background-color: #cecece; height: 50px; text-align: center; } th.op{ color: black; width: 450px; background-color: #cecece; height: 50px; text-align: center; } .a{ height: 25%; cursor: pointer; } button{ width: 100%; height: 100%; margin: -5 auto -5 auto; } textarea { height: 100%; width: 100%; } .verwijder{ width: 10px; height: auto; background-color: #ffa8a8; } .space{ width: 20px; height: auto; } .invoegen{ background-color: #6dbbdc; width: 1434px; padding: 5px; margin: 5px; } .content{ background-color: #FFDD67; width: 1500px; ; padding: 0 5 0 5; margin: 0 5 0 5; } .content table{ margin-bottom: 100px; } span{ text-decoration: underline; } select{ height: 90%; } </style> <div class="content"> <?php mysql_connect("localhost", "************", "*********") or die(mysql_error()); mysql_select_db("*********"); $sql = "SELECT ID, NAAM, CONTACT, TOEGEZEGD, bestuur1, bestuur2, bestuur3, bestuur4, bestuur5, VORM, PAKKET, KANGEFACTUREERD, GEFACTUREERD, AANTAL, POST, OPMERKING FROM `sponsoren` ORDER BY $field $sort"; $result = mysql_query($sql) or die(mysql_error()); echo'<table>'; while($row = mysql_fetch_array($result)) { $BESTUUR1 = $row['bestuur1']; $BESTUUR2 = $row['bestuur2']; $BESTUUR3 = $row['bestuur3']; $BESTUUR4 = $row['bestuur4']; $BESTUUR5 = $row['bestuur5']; if ($row['TOEGEZEGD'] == 'ja') { $NewClass = "JA" ; } elseif ($row['TOEGEZEGD'] == 'nee') { $NewClass = "NEE"; } elseif ($row['TOEGEZEGD'] == 'misschien') { $NewClass = "MISSCHIEN"; } echo $NewClass; echo'<tr> <td><a href="full_table_row_results.php?ID='.$row['ID'].'">'.$row['ID'].'</a></td> <td>'.$row['NAAM'].'</td> <td>'.$row['CONTACT'].'</td> <td >'; if($BESTUUR1 == 1){ echo "<div class='item'><label>Kk</label></div>"; }; if($BESTUUR2 == 1){ echo "<div class='item'><label>Rutger</label></div>"; }; if($BESTUUR3 == 1){ echo "<div class='item'><label>Toby</label></div>"; }; if($BESTUUR4 == 1){ echo "<div class='item'><label>Meijke</label></div>"; }; if($BESTUUR5 == 1){ echo "<div class='item'><label>Boele</label></div>"; }"</td>"; echo'<td class = "$NewClass">'.$row['TOEGEZEGD'].'</td> <td class = \"$New$Class\">'.$row['VORM'].'</td> <td><DIV CLASS="$NewClass">'.$row['PAKKET'].'</DIV></td> <td>'.$row['KANGEFACTUREERD'].'</td> <td>'.$row['GEFACTUREERD'].'</td> <td>'.$row['AANTAL'].'</td> <td>'.$row['POST'].'</td> <td class = "op">'.$row['OPMERKING'].'</td>'; echo'</tr>'; } echo'</table>'; ?> </div> </body> </html> I recently put together a form for a client - I am not a programmer (designer) but it worked really until we tried to put the name of a city. It wouldn't take abbreviations that the post office uses
I need to do one of two things - allow it to take abbreviations or take off the requirement that the field has to be filled out.
HELP
Here is the code.
<li class='field_block' id='field_3_div'><div class='col_label'> Hi guys, I'm trying to create a script which changes on curtain times, heres a example: 3pm - Dance Session 4pm - Indie Session 5pm - RnB Session What i want the desired outcome to be is Display current time with whats playing (say its 3pm) 3pm - Dance Session Then at 4 i want it to remove the 3pm and display the 4pm - Indie Session Is it possible? If so how? Many thanks for you time guys! J |