[Solved] Dynamic key value type

You have to decode data depending on type. That means you have to first decode type and then continue depending on its value. Usually to store such items we would use an enum with associated values: enum Item: Decodable { case onboarding(OnboardingData) case entry(EntryData) init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) … Read more

[Solved] execute query with cakephp [closed]

you ca us this code $mat=$this->Materiel->Paiement->query(” select *,materiel_id , SUM(paiements.quantite) as t from paiements ,materiels where paiements.materiel_id=materiels.id GROUP BY materiel_id ORDER BY sum(paiements.quantite) desc “); Ajust this code for your model 1 solved execute query with cakephp [closed]

[Solved] How to get base64 encoded value from url in javascript variable

First get the value from the url into a php variable like this : <?php $x = base64_decode($_GET[“prod_id”]); ?> Then save this value into a hidden text field like this : <input type=”hidden” id=”product_id” value=”<?php echo $x; ?>”> Then get this value from the hidden textfield to javascript variable. $(document).ready(function(){ $value = $(“#product_id”).val(); } 1 … Read more

[Solved] Need a little with an audio player in java [closed]

First of all, if you want to play sounds that aren’t looped and are longer than a few seconds, you shouldn’t be using Clips. You’re going to need to use SourceDataLines, which can read audio data in several different formats (consult AudioFileFormat.Type for specifics) via streams. As for your questions: Mixers, Lines, and Ports are … Read more

[Solved] php date change to 12 hour format and add gmt +3 [closed]

If you want the GMT +3 timezone, you could apply this: date_default_timezone_set(‘Etc/GMT+3′); Although I don’t recommend it because PHP will not longer support that timezone. You might use one of the supported ones. And for the date being in 12-hour format use it this way: $date = date(‘m-d-Y h:i:s’); Lowercase h format character is for … Read more

[Solved] communication between two objects [closed]

There isn’t much context for what you want soooo… var ob = function(){ }; ob.prototype.func = function(data){ console.log(data); }; ob.prototype.setPartner = function(obj){ this.partner = obj; }; ob.prototype.comm = function(){ this.partner.func(“data”); }; var o1 = new ob(); var o2 = new ob(); o1.setPartner(o2); o2.setPartner(o1); o1.comm(); PS this will create circlular objects solved communication between two objects … Read more

[Solved] Squaring the odd number and squaring the number-1 if number is even [closed]

Here is easy sample code to understand: def odd_square(number): if number == 0: return 0 elif number % 2 == 1: return number*number else: return (number – 1)*(number – 1) square = odd_square(int(input(“Enter number to square: “))) print(“square is: “,square) you need to convert number to integer as input() returns string. TypeError: odd_square() takes 0 … Read more

[Solved] JavaScript function not running? [closed]

The main problem is that your global var userChoice has the same name as the function’s argument. The function getUserChoice over writes it’s parameters value with the values set in the conditionals. Then it does nothing with it; once you leave the function’s scope, it’s lost. If you want the function to operate on the … Read more

[Solved] Can I change the datatype of previously declared variable in C?

Since the pointer returned by malloc() is sufficiently well aligned to be used as a pointer to any type, you could (but probably shouldn’t) use: assert(sizeof(float) <= 10); void *data = malloc(10); char *str = data; strcpy(str, “123.4”); float *vp = data; *vp = strtof(str, NULL); …use *vp… free(data); And now you can use *vp … Read more

[Solved] Multiple Checkboxes

$name = $_POST[‘name’]; $email_body =”; <?php $aDoor = $_POST[‘formDoor’]; if(empty($aDoor)) { $email_body = “You didn’t select any buildings.”; } else { $N = count($aDoor); $email_body .= “You selected $N door(s): “; for($i=0; $i < $N; $i++) { $email_body .= $aDoor[$i] . ” “; } } ?> 0 solved Multiple Checkboxes