php

send and retrieve key-value pair between php and jquery ajax?

i use $.get to run php file. how can i send key-value pair (eg. variables) from the php-file to jquery? and when sent, how can i retrieve them with jquery? i want to validate eg. if(key == value) in jquery. and what is the difference between $.getJSON and $.get? if i want to run php i cannot use $.getJSON? i tried in the php file use: ...

What functions are necessary to program a PHP script that can interact with an AJAX website like a normal browser?

I want to know what is necessary to create a PHP script that can interact with a website like a normal browser. The website would be rich in Ajax, so the PHP script needs to know how to handle Javascript functions and maintain an continuous connection with the website. ...

How to let users add multiple tags using PHP and MySQL?

Okay, so I already have a script to let users enter tags but I want to let users enter multiple tags that are separated by a comma for example, (html, css, php) and store each tag in the database. Is there a tutorial that can show me how to do this or can someone give me a couple of examples that i can work from. Thanks ...

Warning: exif_imagetype(test.gif) [function.exif-imagetype]: failed to open stream: No such file or directory in E:\xampp\htdocs\online\upload.processor.php on line 6

Warning: exif_imagetype(test.gif) [function.exif-imagetype]: failed to open stream: No such file or directory in E:\xampp\htdocs\online\upload.processor.php on line 6 What's wrong? How to fix it? Maybe I should get the full path of the file on the client. How to do it? ...

Why Aren't the _construct() Methods on EAV Resources and Collections Declared as Abstract Methods?

I've been poking around the bowels of Magento systems code. For "regular" model resources, Magento's _construct initialization convention has been declared abstract File: Mage/Core/Model/Resource/Abstract.php abstract protected function _construct(); This makes sense, as it forces developers creating their own Model resources to call...

How to select the latest version of answers given by each answerer in MySQL?

There is a scenario. There is an ask-and-answer website. An answerer can modify his answer, and the history of modification is saved on the server. Be default, only the latest version of each answer is displayed. select * from answers where questionid='$questionid' group by answerer_id So I can group all answers by answerer, then I ...

How do I "add" strings in PHP - not concatenate, but "add" them. (as if each character was a base 36 numbers)

Unfortunately I inherited some code (c/c++) that does some string manipulation and now I need to copy/port that over to php so this functionality can be accessed over the internets. Specifically the functionality takes some arbitrary strings and "adds" them together. (the c code iterates down the character array and then does some ch...

json jquery php question

i dont understand one thing. if i want to get JSON data (key-value-pairs) from php to jquery using ajax...which of these following ones should i use? $.get $.post $.getJSON do i need to use getJSON if i want to use json_encode in php file? but what if i want to send with post? (there is no postJSON)? and one more thing: in php fil...

Are there performance issue of using while loop vs foreach/for loop?

What are the performance issue of using while loop v/s foreach/for loop or vice-versa ? Also is it always preferable to use foreach loop v/s while in php ? ...

just php no javascript

Just using php, is it possible to create a button via html that reacts to the user's input, for example, if the user clicks the button 4 times, something is suppose to happen, or do I need javascript. Likewise if the user clicks the button twice or three times something different is suppose to happen, is this possible, if so, what do I...

Javascript - How to change a new value on drop down

When we change the name="quantity" and the $product['price'] value will changing too. Here will have dynamic quantity and price. How to do that using jquery/javascript. <?php $select = "SELECT * FROM `products` ORDER BY `id` DESC LIMIT 10"; $query = mysql_query($select) or die(mysql_error()); ?> <ul> <?php while($product = mysql_...

jquery ajax get json array?

i use $.getJSON to call php file. it echos this back. for($i=0; $i<=10; $i++) { $nr[] = $i; } echo "{'result': 'error', 'count': '$nr'}"; in jquery to get result i just use alert(data.result) how do i get all the nr:s in count? EDIT: But how do i loop the array through in jquery? All the keys are numeric and i dont know how to...

PHP/MySQL - How to add multiple tags

I have this script that only lets users enter a single tag but I want to let users enter multiple tags that are separated by a comma for example, shoe, shirt, hat, glasses and store each tag in the database. Can someone please give me a couple of examples of what I need to change in my script in-order to do this. Here is my MySQL tabl...

php sessions and determining if x value has been selected via sessions

Problem, I want to use sessions, but I am having issues with implementing sessions from my $food array such that if the user has selected a Pizza, I don't offer him or her a sandwich, likewise if the user selects a Sandwitch, I don't offer the user a Pizza. I also want to know if the user has already selected a Pizza or Sandwich. ...

add new session product - PHP

When a user is buying a product (lets say they have 3 products) and they have typed their information, the product automatically goes into database with a status = 0. If the user is going away from the basket, lets assume into product overview(and buying an extra product, now they have 4 products in basket). I have to find out how to...

let jquery know which was the last visited php page?

this is a little bit tricky. usually when someone clicks on a link that requires him to register, this person will be redirected to the registration page and then back to the last visited page. this is possible cause the link sent a GET key through the url to the registration.php which uses the key to go back to last visited page. but ...

Draw an 8x8 square on an image

I have an image: image.png (could be jpg or gif) How can I draw an 8x8 square at $x, $y and then save the image to $file? ...

Question about an array in gallery2

I'm working on a modification from a theme in the open source project "gallery2". Here is the code that I am looking at: For anyone familiar with it, its in the SearchShowAll.tpl file in the search module in the modules section of the download. <ul class="giInfo"> {foreach from=$result.fields item=field } <li> ...

Storing multiple tags in a MySQL database problem using PHP/MySQL?

First let me explain that I have this script that should let users enter multiple tags that are separated by a comma for example, shoe, shirt, hat, glasses and store each tag in the database. But for some reason the tags are not being stored in the database correctly. For instance when a user enters two or more tags they are stored all...

How can I simplify this PHP?

I have the following model functions with PHP. I know I am repeating myself. Is there anyway I can simplify this code? function getTopMenus(){ $data[0] = 'root'; $this->db->where('parentid',0); $Q = $this->db->get('menus'); if ($Q->num_rows() > 0){ foreach ($Q->result_array() as $row){ $data[$row['i...