[Solved] Creating json data with duplicate keys [closed]

PHP comes with a JSON extension. The only thing you will need to figure out is how you have to create the data in PHP. [] in JSON is an array, {} is a dictionary. For the part mentioned you’ll need something like this: $foo = array( array( ‘c’ => array( array(‘v’ => ‘date3’), array(‘v’ … Read more

[Solved] PHP usort item missing keys to top [duplicate]

return 1; in your first if there makes no sense – returning 1 means, $a is supposed to be considered greater than $b. So whenever either one of them is missing that value, you always say the first one should be considered the greater one. The return value of the callback function only decides, whether … Read more

[Solved] How can I split a semicolon delimited string into separate item from string?

You can use explode function. explode link $str = “Loganathan <[email protected]>; Nathan <[email protected]>; Tester <[email protected]>;”; $str = str_replace(array(” <“,”>”),array(“, “,””),$str); $converted = explode(“;”,$str); print_r($converted); Which gives you output like Array( [0] => Loganathan, [email protected] [1] => Nathan, [email protected] [2] => Tester, [email protected] ) 2 solved How can I split a semicolon delimited string into separate … Read more

[Solved] Undefined Index inside a While PHP

The field “candidateid” should be integer data type, but you are enclosed this field value with ”(single quotes) in the update query? $sql = “UPDATE candidate_info SET numberofvotes = 1 WHERE candidateid = ‘$candidateid'”; if it is an integer datatype then you should remove the single quote $sql = “UPDATE candidate_info SET numberofvotes = 1 … Read more

[Solved] Check a Website is Responsive or not using PHP [closed]

Thanks to @Alexander O’Mara for the suggestion. It’s little trick. Not 100% correct way. But working for all sites. <?php ini_set(‘user_agent’, ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9’); $html = file_get_contents(“http://php.net/”); ini_set(‘user_agent’, ‘Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7’); $html2 … Read more

[Solved] Get substrings from an array rows, Regex? [closed]

$str=”2015/2016-0 5 Gruuu 105 Fac Cience Comm 10073 Com Aud 103032 Tech Real TV 4 First Time feb First Quad 6.0 1 Lory Johnson, Nicholas 1334968 47107453A Cory Stein, Hellen Monster Cr. pie 5 a 3-2 08704 Iguan NewYork [email protected] [email protected] 617788050 Si 105 / 968 17/07/2015 0″; Get 6 numbers: preg_match(‘~\d{6}~’, $str, $matches); print_r($matches); … Read more

[Solved] jquery mobile & php

Here you go, fixed it: PAGE 1: index.html <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script> <script src=”https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js”></script> <link rel=”stylesheet” href=”https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css”> <script type=”text/javascript” src=”http://dev.jtsage.com/cdn/spinbox/latest/jqm-spinbox.min.js”></script> </head> <body> <div data-role=”page”> <h1 id=”header”>IT Cafe</h1> <a href=”#hot” data-role=”button” data-inline=”true” data-icon=”home” data-iconpos=”notext” id=”homeicon” ></a> <a href=”#shop” data-role=”button” data-inline=”true” data-icon=”shop” data-iconpos=”notext” id=”shopicon” ></a> <nav data-role=”navbar”> <ul> <li><a href=”#hot” class=”ui-btn-active ui-state-persist” >Coffee(Hot)</a></li> <li><a href=”#ice” … Read more

[Solved] Php variable not getting incremented in jquery

Fixed session issue : $.ajax ({ url : “test.php”, type : “post”, data : { “categoryIds” : categoryIds }, dataType : “json”, success : function(resp){ var html = “”; var i = 1; <?php $j = 1; ?> $.each(resp,function(key,questions ){ var testdataIndex = “answer_” + i ; var filename = “getsession.php?sessionName=”+testdataIndex; $.get(filename, function (data) { … Read more

[Solved] Displaying data from 2 tables as links

Consider this an example: First you have to extract those values using PHP. After the extraction, you can now present it on HTML. You can use a dropdown box (here in this example), to select which category you want to see. index.php <?php // use $_GET variable for your query $category = (isset($_GET[‘category’]) && $_GET[‘category’] … Read more

[Solved] How can I transfer data from php back to HTML?

$files = glob(); <img src=”https://stackoverflow.com/questions/34179608/$files[0]” /> <img src=”$files[1]” /> You can use forloop to show all images. <?php for($i=0;$i<count($files);$i++){ ?> <img src=”https://stackoverflow.com/questions/34179608/<?php echo $files[$i] ?>” /> <?php } ?> 3 solved How can I transfer data from php back to HTML?