Skip to content
Advertisement

Tag: php

Inserting MySQL results from PHP into JavaScript Array

I’m trying to make a very simple autocomplete function on a private website using a trie in JavaScript. Problem is the examples I have seen and trying are just using a predefined list in a JavaScript array. e.g. var arrayObjects = [“Dog”,”Cat”,”House”,”Mouse”]; What I want to do is retrieve MySQL results using PHP and put them into a JavaScript array.

HTTP Content-Type Header and JSON

I have always been trying to avoid using most of the HTTP protocol’s properties for the sake of fear of the unknown. However, I said to myself that I’m going to face fear today and start using headers purposefully. I have been trying to send json data to the browser and use it right away. For example, if I have

Passing string variable with spaces

In the following code: ‘set’ is a string variable which can have spaces in it. I’m noticing when it has spaces it’s not working correctly. How can I fix this? EDIT: For clarity, I’d like to keep the spaces intact. Answer You have to replace intermediate space (‘ ‘) with ‘%20’ using replace(), and eliminate boundary spaces (‘ ‘) using

Get today coptic date

I’m looking to get coptic date of today with any code type like php or javascript to display coptic date to my site header. I need it in arabic or english. I have tried to find it, but didn’t found any thing like it in english. Reference: http://www.copticchurch.net/easter.html http://www.ortelius.de/kalender/coptic_en.php http://en.wikipedia.org/wiki/Coptic_calendar Answer Here is the extension of the DateTime class. Use

Detect user exit site

I have an urge to detect when a user leaves my site in order to record accurately the session length of the user in question. I have thought of a couple possible solutions for this: I first thought I could use onbeforeunload and send a simple ajax to record the last activity but what practice has shown me is that

HTML form dropdown menu specify number range

I want to specify number range in drop-down menu list like 1-24 from example i am currently doing following is there any way we can say use 1-24 and it dynamically create drop-down menu, I guess we need to use Javascript but i don’t know how to code them? Answer You don’t need Javascript, you can use a PHP for

Advertisement