Jump to content

Jeisson

Members
  • Content Count

    40
  • Joined

  • Last visited

Everything posted by Jeisson

  1. I know what the customer wants it to do. And the serverside data is now in a text file .dat I put the same data in a .json file and fetch the data from there and handle it with javascript. I don't see a problem there. However I found out this code actually works on the current customer server. But not on my test server(s). Thanks for all comments.
  2. ok thanks i think I'll suggest a complete rewrite. I am not good at php, so I would do this in javascript. but thanks for your analyzis and advice. I appreciate
  3. Thank you for your answers. the script is supposed to add correct filenames from .dat files so that in the html there would be correct images. these are chosen with drop boxes. also populate the dropboxes. this script i got from customer. it used to work a few years ago. hope this part help function rowColour($row) {return ($row % 2 == 0 ? "listrow01" : "listrow02");} function readObjectsFromFile($file_name){ $file_rows = file($file_name); $object_list = array(); for($i=0;$i<count($file_rows);$i++){ $object = __unserialize($file_rows[$i]); $object_list[count($object_list)] = $object; } return $object_list; } function getFramesFromFile(){ $frames_list = readObjectsFromFile("styles/frames/frames.dat"); return $frames_list; } function getMirrorsFromFile(){ $mirrors_list = readObjectsFromFile("styles/mirrors/mirrors.dat"); return $mirrors_list; } function getPricesFromFile(){ $prices_list = readObjectsFromFile("prices.dat"); return $prices_list; } function getDefaultDoorFromFile($index){ $door_list = readObjectsFromFile("styles/defaultdoor.dat"); $door = $door_list[$index]; return $door; } function getDefaultFrame($index){ $door = getDefaultDoorFromFile($index); return $door->frame; } function __serialize($object) { $serialized = serialize($object); return htmlentities($serialized,ENT_QUOTES); }
  4. I have problems with a script. The error log says I should change the preg_replace to preg_replace_callback I dont know how to do it, so please help. function __unserialize($string) { $unserialized = stripslashes($string); $unserialized = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $unserialized ); return unserialize($unserialized); } Edit: I did try to do it. so if you want to see what I tried I ofcourse can show. But it reutned a blank screen
  5. I have an iframe in a html or php site (tried both) and it works fine on Firefox and my mobile browsers. But Chrome behaves badly. The iframed php page contains a form and when I send it the whole iframe disapears. But it reapears when "painting it with my mouse". no cliks needed. just some mouseover/hovering. The whole iframe don't appear at once but small part of it. Therefor the "painting expirience". It is annoying because the visitor don't kmow to do this. Sorry, but i dont know how to explain this any better. the form is a domain lookup form (whois).
  6. I have a php file in a iframe from where I take a form result to the parent with following jquery code. In the example there is both appendTo to a <p> and an input element. Anyway works fine on desktop browsers as far as I have tested, but not on my phone . <script> $('#order').click(function() { var free = $('#iframeid').contents().find('#free').text(); $("<span>"+free+" </span>").appendTo("#g"); $('.g').val($('.g').val() + vapaa); }); </script> <button id="order">'order domain</button> <p> <div id="wrap"> <p id="g"></p><p> <input type="text" class="g" id="inputbox" name="input" placeholder="www.example.com" width="100px"/> </div> Any other solutions? I managed only to make these. Preferable I use input text element. The span was just for a test. Thanks.
  7. Ok now I realize. I thought in my case they would be valid but that is not the case. Need to re-think the whole thing now. Something like decoding each file and then getting what I am lookin for and store that as new json. Whole merging and concatening I think I do not need..
  8. yeah I will see. My json files are not ready yet. So I will work on them when I have the code that does something with them. Iḿ just such a noob. May I ask why first code works json_decode($complete_json,true); var_dump($complete_json); while this not. $content = json_decode($complete_json,true); var_dump($content); I just don see the logic always
  9. I don't yet have any better approach I'm just thinking out loud. I will need to try and test. this was first step. Are you suggesting it would be safe way to decode everything then array_merge and encode this to json?
  10. thank you I will continue from here. The json files have all same structure so I thought I could merge them to one. But if that will not work I will try to get a specific key from each files directly. Maybe something like that would be better anyway.
  11. Hello I have several json files in one directory. i would like to merge them in to one. I did something like this <?php foreach (glob("../json/*.json") as $filename) { echo basename($filename) . "\n"; } $res1 = file_get_contents($filename); echo $res1; ?> But it echoes only the last (the first echo is to view all files which is not important here) Then I tried many versions of foreach inside foreach with no success. Like this: <?php foreach (glob("../json/*.json") as $filename) { foreach (file_get_contents($filename) as $a) { } } echo $a; ?> So I appreciate a little help here, thank you.
  12. started a new topic on xml -> SELECT (option) with jquery n example
  13. Hello I would like to populate the select onload. or document ready with jquery I dont see why not working' <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>xml to select</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script> $(document).ready(function() { $.ajax({ type: "GET", url: "test.xml", dataType: "xml", success: function(xml) { $("#myDiv").append("<select id='mySelect'>"); $(xml).find('value').each(function(){ var a = $(this).text(); $("#mySelect").append("<option class='nice' value='" + a + "'>" + a + "</option>"); }); $("#myDiv").append("</select>"); } }); }</script> </head> <body> <div id="myDiv"></div> </body> </html> Thank you for your advice.
  14. ok. maybe I should directly do it that way then. i just thought i could "manually" do like I was asking first. I know how to get json to array. havent done before select populsting or what should i call it..
  15. I get that. But wont work in my case. I need the value to be dynamical. I will get it from a json or similar. So Now I thought to get it from an Array. Afterwards I parse the json to that specific array.
  16. Hello there friends I have an select box and I would like to define the alue of the selects with array. Like this: var price_list= new Array(); price_list["-"]=0; price_list["bronze"]=5; price_list["silver"]=10; price_list["gold"]=15; The I have a Selectbox where <form action="" id="metal" onsubmit="return false;" <select id="a" name="metals" class="form-select"> <option value="-">-</option> <option value="bronze">bronze</option> <option value="silver">silver</option> <option value="gold">gold</option> </select> And performig calculations with following script (that works fine if the value is directly in select). And obviously there is another select (#b) but that is just numbers so I didn show it here. $(document).ready(function() { function compute() { var a = $('#metals').val(); var b = $('#b').val(); var total = a * b * 1.22; $('#result').text(total); } $('#metals, #b').change(compute); }); I just get returned NaN If you have an answer then please hit
  17. I solved it by changing echo to print_r and skipping the ajax for now and wrote php file_get_contents snippet instead I suspect there is something in the ('up') and ('down') that needs to be printed properly. I use (\'up\') and works fine wit php but not ajax
  18. Yes sorry I should have had that. I try to show essential code. //first some html like this <div id="scrollable-v1" class="scrollable"> <div class="belt"> <?php //then here are some api stuff //echoing and parsing and echoing like below shortened foreach ( $es as $it){ echo '<li>'; echo '[<all kind>]; foreach ( $ve as $ti){ echo 'a lot if text and stuff like that'; } } ?> </div> </div> <div class="skroll"> <img src="up.png" onMousedown="scrollv1.scrollContent('up')" onMouseup="scrollv1.stopScroll()" class="up"> <img src="dwn.png" onMousedown="scrollv1.scrollContent('down')" onMouseup="scrollv1.stopScroll()" class="dwn"> </div> code up works if I run in browser copypaste the output and save as a txt file. So I tried to do this saving with php. Like this here down //auto txt file code <?php // here are some api stuff //echoing and parsing and echoing like below shortened echo ' <div id="scrollable-v1" class="scrollable"> <div class="belt">'; ob_start(); //this is different from upper foreach ( $es as $it){ echo '<li>'; echo '[<all kind>]; foreach ( $ve as $ti){ echo 'a lot if text and tuff like that'; } } echo ' </div> </div> <div class="skrollit"> <img src="up.png" onMousedown="scrollv1.scrollContent(\'up\')" onMouseup="scrollv1.stopScroll()" class="up"> <img src="dwn.png" onMousedown="scrollv1.scrollContent(\'down\')" onMouseup="scrollv1.stopScroll()" class="dwn"> </div>'; $content = ob_get_contents(); file_put_contents('output.txt', "\xEF\xBB\xBF". $content); ?> Sorry if my shortening made it a mess. anyway diff services find no difference. nor do I. Started to think maybe it saves in other format? The txt file is used in jquery ajax load wordpress
  19. Hi When I have a file that echoes some stuff and I press view source and copy paste the source and manually makes this to a .txt file Something different happening somewhere comapred to if I have ob_start() //before the content ob_get_contents and file_put_contents //after to make the text file. I' do get a text file. It looks the same. the content is the same as my manually made. But when I load it with ajax in to my div only the manually made is scrollable. the scroll is made with .js What is going on here?
  20. Resolved. I didn´t find trough googeling nyesterday but today I found easily an alternative. I use before the desired content ob_start(); and after $content = ob_get_contents(); file_put_contents('output.txt',$content);
  21. I was hasting. Did not notice thius does not give desired result. this system gives all info, but it makes two different list. first all of $s1 then all of $s2 what I wanted is like the echo did. ie. $s1 Venue1 $s2 Date1 - Ti1 $s1 Venue2 $s2 Date2 - Ti2 $s1 Venue3 $s2 Date3 - Ti3 and so on
  22. Tried it. worked partially. but full solution was simply to do the same "trick" fo $s1 and that was it.
  23. wau beautiful. so many details in this language. I have not yet tried it but sounded convincing. Thank you.
  24. Hello I have problem to get the whole loop saved in to a file. I seams to save only the last "section" So I have two json files that I decode and managed to echo as I wanted. Now plans changed and I want to save what was echoed in to a file instead. I planned to use file_put_contents for that. My code looks like this but it did not put the whole list in to the file. just one. (I show you only the foreach and attempted file saving. <code> foreach ( $venues as $item){ $s1 = '<li style="padding-top:15px;">' . '<a target="_blank" href="http://foursquare.com/v/' . $item['id'] . '">' . $item['name'] . '</a></li>'; $endpoint2 = 'venues/' . $item['id'] . '/tips'; $params2 = '?limit=1'; $url2 = $base_url.$endpoint2.$params2.$auth; $results2 = file_get_contents($url2); $json_results2 = json_decode($results2,true); $venues2 = $json_results2['response']['tips']['items']; foreach ( $venues2 as $ti){ $s2 = '<li>' . '<span>' . date('j.n.Y',$ti['createdAt']) . '</span>' . ' - ' . $ti['text'] . '</li>'; } } file_put_contents('output.txt',$s1 . $s2); //echo $s1 . $s2; //for quick check </code> If I remove the $s1 and respectively $s2 and put the echo instead I get the whole result on my screen. So why is this only taking the last <li><a href="url and result and so on in to the file? This forum did not allow me to format my text, so appologises for that.
  25. Sorry guys. I have too many tabs open. Here is correct json. It is truncated because it is very long. {"meta":{"code":200,"requestId":"561d68a0498ed5ffa3210d59"},"response":{"suggestedFilters":{"header":"Tap to show:","filters":[{"name":"Open now","key":"openNow"},{"name":"With specials","key":"specials"}]},"geocode":{"what":"","where":"london","center":{"lat":51.50853,"lng":-0.12574},"displayString":"London, Greater London, United Kingdom","cc":"GB","geometry":{"bounds":{"ne":{"lat":51.691643999655895,"lng":0.33418999705203406},"sw":{"lat":51.28467404417054,"lng":-0.5085579279369435}}},"slug":"london","longId":"72057594040571679"},"headerLocation":"London","headerFullLocation":"London","headerLocationGranularity":"city","query":"food","totalResults":246,"suggestedBounds":{"ne":{"lat":51.51263103703768,"lng":-0.12231439480184818},"sw":{"lat":51.50654795865553,"lng":-0.1314193179278593}},"groups":[{"type":"Recommended Places","name":"recommended","items":[{"reasons":{"count":0,"items":[{"summary":"This spot is popular","type":"general","reasonName":"globalInteractionReason"}]},"venue":{"id":"4ac518c4f964a5209aa420e3","name":"Wahaca","contact":{"phone":"+442072401883","formattedPhone":"+44 20 7240 1883","twitter":"wahaca"},"location":{"address":"66 Chandos Pl","lat":51.51022652594927,"lng":-0.12449473142623901,"postalCode":"WC2N 4HG","cc":"GB","neighborhood":"Covent","city":"London","state":"Greater London","country":"United Kingdom","formattedAddress":["66 Chandos Pl","London","Greater London","WC2N 4HG","United Kingdom"]},"categories":[{"id":"4bf58dd8d48988d1c1941735","name":"Mexican Restaurant","pluralName":"Mexican Restaurants","shortName":"Mexican","icon":{"prefix":"https:\/\/ss3.4sqi.net\/img\/categories_v2\/food\/mexican_","suffix":".png"},"primary":true}],"verified":true,"stats":{"checkinsCount":5406,"usersCount":4132,"tipCount":177},"url":"http:\/\/www.wahaca.co.uk","price":{"tier":2,"message":"Moderate","currency":"£"},"hasMenu":true,"rating":9.1,"ratingColor":"00B551","ratingSignals":534,"menu":{"type":"Menu","label":"Menu","anchor":"View Menu","url":"https:\/\/foursquare.com\/v\/wahaca\/4ac518c4f964a5209aa420e3\/menu","mobileUrl":"https:\/\/foursquare.com\/v\/4ac518c4f964a5209aa420e3\/device_menu"},"allowMenuUrlEdit":true,"hours":{"status":"Open until 11:00 PM","isOpen":true},"specials":{"count":0,"items":[]},"photos":{"count":220,"groups":[]},"hereNow":{"count":0,"summary":"Nobody here","groups":[]}},"tips":[{"id":"51decb2b498ee8a050cbd86b","createdAt":1373555499,"text":"Baharata düşkün Meksika Mutfağını seviyorsanız mutlaka uğrayın lezzetli ve uygun fiyatlı .","type":"user","canonicalUrl":"https:\/\/foursquare.com\/item\/51decb2b498ee8a050cbd86b","photo":{"id":"51decb2d50193b64eed0a5d3","createdAt":1373555501,"source":{"name":"Foursquare Web","url":"https:\/\/foursquare.com"},"prefix":"https:\/\/irs0.4sqi.net\/img\/general\/","suffix":"\/25407761_lcYmk9RXyoRZG0M8_1_DuW0oYSpCJy7CV_Iad-z78qs.jpg","width":1600,"height":1200},"photourl":"https:\/\/irs0.4sqi.net\/img\/general\/original\/25407761_lcYmk9RXyoRZG0M8_1_DuW0oYSpCJy7CV_Iad-z78qs.jpg","likes":{"count":32,"groups":[],"summary":"32 likes"},"logView":true,"todo":{"count":1},"user":{"id":"25407761","firstName":"Tugba","lastName":"Söyler","gender":"female","photo":{"prefix":"https:\/\/irs2.4sqi.net\/img\/user\/","suffix":"\/25407761-LOAJ2FBBDEDFAOPG.jpg"}}}],"referralId":"e-3-4ac518c4f964a5209aa420e3-0"},{"reasons":{"count":0,"items":[{"summary":"This spot is popular","type":"general","reasonName":"globalInteractionReason"}]},"venue":{"id":"53bab96d498e7e355fb53d6c","name":"Barrafina","contact":{"phone":"+442074401456","formattedPhone":"+44 20 7440 1456","twitter":"barrafinaadst","facebook":"705351912878392","facebookUsername":"BarrafinaAdelaideStreet","facebookName":"Barrafina Adelaide Street"},"location":{"address":"10 Adelaide St","crossStreet":"William IV St","lat":51.50945052890648,"lng":-0.1259482415312226,"postalCode":"WC2N 4HZ","cc":"GB","city":"London","state":"Greater London","country":"United Kingdom","formattedAddress":["10 Adelaide St (William IV St)","London","Greater London","WC2N 4HZ","United Kingdom"]},"categories": it is foursquare api with explore as parameter. the first json was with an another parameter. https://developer.foursquare.com/docs/venues/explore shuffle($results) is error because results is not array "Warning: shuffle() expects parameter 1 to be array, string given"
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.