php

searching mySQL by first char(s) in fields with php

I have a database that's setup in the following way id coach team event status 14 test 8,7,12,13,15 4,1,2,14,4 2 13 test 8,12,13,14,15,16 1,2,8,16,16 3 What i need to do, is search for rows where the first number in the "event" column matches the query. They are s...

How to search using the LIKE syntax and % WILDCARD % across multiple tables.

How can you use mysql and the like/wildcard syntax across multiple tables, would it be as simple as: (SELECT * FROM `table1` WHERE `name` LIKE '%tom%') AND (SELECT * FROM `table2` WHERE `name` LIKE '%sam%') Not tested, just thinking about it. ...

Smart (?) Database Cache

I've seen several database cache engines, all of them are pretty dumb (i.e.: keep this query cached for X minutes) and require that you manually delete the whole cache repository after a INSERT / UPDATE / DELETE query has been executed. About 2 or 3 years ago I developed an alternative DB cache system for a project I was working on, the...

HTTP POST requests in PHP

How do you go about redirecting a browser and sending a HTTP POST request in PHP? A header("Location: file.php?foo=bar") of HTTP POST requests, if you will. ...

What does '<?=' mean in PHP?

<?php $a=1; ?> <?=$a;?> What does <?= mean exactly? ...

prepopulating PDF forms in PHP using FDF or XFDF

I have a XFDF PDF created for me and want to populate the fields in this XFDF document. I am using PHP 5.2 Any ideas? THanks :) ...

PHP - intersecting multidimensional array of varying size

I have a multidimensional array that looks like this: Array ( [0] => Array ( [0] => Array ( [id] => 3 ) [1] => Array ( [id] => 1 ) [2] => Array ( [id] => 2 ) [3] => Array ...

Calculating the time difference in an php/mysql/javascript system

I was wondering what the best way is to calculate the difference in time from now to a certain point, lets say the countdown time. I have an auction that has a closetime at a certain point, this time is stored in an mysql record in the format " DATETIME 00-00-000 00:00:00 ". This record is called closetime. Now on my website i have a j...

Session is saving only records and it's not saving the rest of the records in PHP?

function mycart($mydate=null,$day=null) { $mycart= $this->session->userdata('mycart'); $totalprice=$this->session->userdata('totalprice'); if($this->limitation($mydate) && (!(isset($mycart[$mydate]))) ) { $mycart[$mydate] = array( 'meal' =>$this->session->userdata('meal'), 'day' =>$day, 'date'...

Good practice to redirect pages?

I remember reading somewhere it's a good practice to redirect pages using GET to show the next page after a POST request. Why is it so? ...

How can I redirect after Facebook.streamPublish() has completed?

I have an application which will post a message on a friends wall using the Facebook.streamPublish() method, and this works perfectly. However, I want to also be able to save details about this post in my database. All the information that needs to be stored is placed into hidden form fields and are all in place once the message has be...

Singleton vs CodeIgniter -style $this to access variables

Hi, I wonder, what are the pros and the cons of these two approaches to access variables: 1) CodeIgniter -style (does this have a name?) public function doSomething() { $database = $this->database; // or just $this->database } 2) The Singleton pattern public function doSomething() { $database = Framework_Database::getInstance(); ...

Simple PHP Crud Generator

I am looking for a simple PHP crud object generator to use with SQL database tables. I've used POG and was wondering if there were any alternatives. ...

Get a column value (like id) after mysql INSERT

Can I get from PHP a value back like the new id from the row I've just added to the database or should I make a SELECT to retrieve it? <?php $sql = "INSERT INTO my_table (column_1, column_2) VALUES ('hello', 'ciao')"; $res = mysql_query ($sql) or die (mysql_error ()); $sql = "SELECT column_id FROM my_table WHERE column_1 = 'hello'"; $...

Get request info in view helper

Hello! Is it possible in Zend View helper (extends Zend_View_Helper_Abstract) get info about module/controller/action in which that helper was called ? ...

Forcing a download using PHP

I have PHP issue, I'm trying to force a file download using php if users click on my link www.site.com/download.php it redirects them to download.php with the following code inside the download.php file header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename=custom_report.csv'); header('Pr...

PHP link list: What's wrong with this script?

The script below should be exluding items that are assigned to the "my-menu" category. However, they are still showing up. Can someone help me identify the logic flaw? <?php global $post; $cat=get_cat_ID('my-menu'); $catHidden=get_cat_ID('hidden'); $count=0; $myposts2=get_posts(array('post__not_in'=>get_option('sticky_posts'),'cat'...

PHP, search and delete files from directory - performance

Hi, I want to delete cache files in a directory, the directory can contain up to 50.000 files. I currently I use this function. // Deletes all files in $type directory that start with $start function clearCache($type,$start) { $open = opendir($GLOBALS['DOC_ROOT']."/cache/".$type."/"); while( ($file = readdi...

Examples of popular, commercial applications written in PHP?

I was just curious to see if I could get together a list of some popular, commercial applications written with the PHP language. I'm just curious what people have built using PHP and how well it seems to fit the application they've developed. Some I know of are: ModernBill WHMCS vBulletin What else is out there? EDIT: To clarify, ...

Any advice for developing for Chrome?

I have a site that I used making CSS,HTML,javascript,Jquery,and PHP. I have made it work on all known browers (IE,FireFox,Safari,ETC...) All of a sudden chrome came out and I looked and my site is jacked. I know this is not a very detailed question but I am just looking for a little guidance for any resources,tips,suggestions on how to...