php

array_multisort to sort several arrays

I've searched for this but can't seem to find the exact answer. I want to use array_multisort to simultanously sort 3 arrays based on numeric values in 3 of the arrays. Basically I want to make a "standings" table similar to what you'd see for NFL/NHL standings etc. I have 3 arrays, tempIDs (string), tempWins (numeric), tempWinPercentage...

receiving data in php through jquery ajax

i just got the hang of using jquery ajax for example, this code sends the contents of the comment box to the php file. $.post("user_submit.php", { comment: $("#comment").text() }); the question however is how do i receive the data in the user_submit.php file? ...

Catalog entries: Updated html files or on-the-fly from database?

I've got a database site that will serve approximately 1,200 primary entries at launch, with the prospect of adding ~100 new entries per year. Each entry would be composed of ~20 basic values from the database, as well as a calculated average rating, and a variable amount of user comments. The rating and comments output would have to be...

Suggest a better flow for a quiz app in CakePHP

Here's the current flow of my quiz app: users/do_program quiz_contents/view quiz_questions/do_quiz The checking if the user has to do another module after finishing the current ones are in the quiz_contents and quiz_questions controller which I think can be improved because of the duplicate code. So what would you guys suggest? Some...

PHP - How to base_convert() up to base 62

I need a base_convert() function that works from base 2 up to base 62 but I'm missing the math I need to use, I know that due to the limitations of PHP I need to make use of bcmath, which is fine. Functions like these convert a number to and from base 10 to another base up to 62, but I want to implement the same functionality of base_co...

$.post not POSTing anything

i am using the following jquery to post comments to user_submit.php var submit = document.getElementById("submit_js"); var comment = document.getElementById("comment"); $("#submit").bind('click', function(){ $.post("user_submit.php", { comment: $("#comment").text() }); }); the user_submit.php listens like: $comment = htm...

isset() or !empty() functions on all variables in your views? PHP

Hi I'm using CakePHP and I'm wondering do you guys puts isset() or !empty() around all of your variables in the views? Or should I depend on the data validation? What would be the suggested solution? ...

Add row value to arraycollection

After I retrieved mysql result from db, I wish to add row number value '1' '2' '3' etc to each results[]. if($products) { while($row = mysql_fetch_array($products)){ $results[] = $row; } ...

JSON output not properly parsed by JQuery?

As it stands, I have some JQuery along these lines - ph=function(i){ $.each(i,function(po){ id=po.id;url="/"+id;t=$('<div id='+ id +' class=entry></div>'); t.html('<div class=hx><a href="/users/'+ po.author +'">'+ po.author +'</a></div><div class=b>'+ po.body +'</div>'); t.prependTo($("#modpskx")); t.hide(); t.slideDown("slow");});}; fu...

How to create a range of IP addresses?

Suppose the input is: 222.123.34.45 and 222.123.34.55 then I need to output the ip address in between them: 222.123.34.45 222.123.34.46 ... 222.123.34.55 ...

PHP array foreach issue

I have an array that I can't seem to get my data back out of. What I would like is for each name (test1...) to have multiple urls associated with them. If you look at the last test (test5), there are 2 urls but this foreach loop only gives me one. Why? Here is the array structure and my foreach loop. Array ( [test1] => Array ...

PHP function or file to run before and after every request

I am wondering if there is a way to specify a php function or file to be called every time a user visits and exits a page on my site. So if a user visits say example.com/ex.php can I have a function called before ex.php is run and after ex.php is finished? I want to be able to record the time it takes to execute php files on my site and...

not able to receive POST data in php file

UPDATE this is the screenshot of the alert: i am using the following JQuery function to successfully POST data to the user_submit.php file, its just that the php file is unable to receive the data. $(function() { $("#submit_js").click(function() { $.post("user_submit.php", { comment: $("#comment").val() }); }...

customize Codeigniter pagination

Is there a way that I can make codeigniter only display "« Older Articles" and "Newer Articles »" instead of displaying page numbers and all the other stuff? ...

PHP Mixing server code with HTML output

I'm coding up a small script that'll take form data and do something with it. If it fails, it shows the error and the form again. If it succeeds, it'll show a success message. The backend code is using classes that'll throw exceptions if there's an error with the form data. The calls to the classes will be wrapped in a try{} catch{}. W...

Using Thrift for PHP to C++ translations

Hey all, I was wondering if anyone had any experience with thrift and could provide an example of taking a PHP array (or object) and translate it into a C++ array (or object). Either that or point me to documentation on how to do this in PHP (which is incomplete on their website!) Thanks! Matt Mueller ...

go back to last state ajax pages?

i've got a website that shows search results with ajax. but of course when i click on a thread in the results and then go back with the web browser back button the results are gone. is there a way to go back to same result page displayed by ajax? cause i really want to use ajax for certain tasks, but it wouldnt be nice if the user has ...

PHP JPEG headers to stop image from downloading

I am currently using the script below to output the contents of a JPEG straight from a file. The reason I'm doing so is because I'm using mod_rewrite/php to mask the name of the original file. This is working partially as expected, except that Safari insists on downloading the photo instead of just allowing me to see it in the browser. A...

Becoming Zend Certified Engineer

Hi, I have seen Zend certified engineers growing fast with upper hand over others. I am also planning to take this exam. I just wanted to know what areas of programming should I be more focused on when preparing for this exam. Any help from zend certified engineers will be greatly appreciated. EDIT Also suggest good resources about t...

MySQL query to get top 10 point-earners in last week?

I'm trying to write a query that returns the user ID's of the top 10 users who gained the most points in the last 7 days on my web app. I have three tables that, together, have the info I need. votingapi_votes table. It has a record for every up/down vote on a comment or node. node table. It can associate a node ID with a user ID so...