php

mysql query taking 30 seconds to execute...too long

I'm trying to run a MySQL query as a search on a site and it is just taking a long time. I ran it directly from phpMyAdmin and it took around 20 seconds to complete. Here is the query I am running: SELECT * , bb_business.id AS bid FROM bb_business LEFT OUTER JOIN bb_offers ON bb_business.id = bb_offers.store_id LEFT OUTER JOIN bb_cat...

Add Additional Objects to JSON Encoded Array

Hi, I am currently using a JSON encoded array to display the users in my database for an auto-suggest feature. It looks something like this: $sth = mysql_query("SELECT id, name FROM users"); $json = array(); while($row = mysql_fetch_assoc($sth)) { $json['name'] = $row['name']; $json['id'] = $row['id']; $...

is there a way to use a view as a menu in drupal?

I want to have a view displayed as a menu either in primarylinks or secondarylinks. I searched and looked up all modules with no luck. should I build this functionality manually ==> build a module? thanks in advance ...

build json object in javascript to post to php

I have a group of radio buttons in a form, I need to pass the values of the selected radion buttons to a php script. So I need to build a json object to post. I tried with this code, but I'm not sure. Please could anyone help me. result = []; for (i=0; i<document.getElementsByTagName('input').length; i++) { if (document.getElements...

Get a subset of random values from an array php

Hi, Starting with an array with 10K values. I want to randomly get 1000 values from it and put them into another array. Right now, I am using a for loop to get the values, but I want to pick 1000 values and not have to loop 1000 times. The array_slice function works, but it doesn't give random values. What is the correct (most effi...

Getting rid of a notice in PHP

Hello everyone, I am creating a from using the Zend Framework version 1.10.7. But I am getting an annoying notice of which I want to get Rid. The notice means that somewehere i have a problem with an array. I just can't find out where it is. Any Help, idea's? Notice: Array to string conversion in /var/www/Zend/ZendFramework-1.10.7...

Custom wordpress page (using plugin)

Hey I want to create a custom page that has tournament brackets instead of the usual content. I have read some of the Wordpress documentation and found how plugins work and how I add admin pages to administer the page. My question is: What is needed to create the page itself (and have it listed on the site)? Do I need to create a custo...

preg_replace() with multiple lines

Dear all, I have trouble again with preg_replace again. I terrible need a book for preg_replace my intention is to replace <td> author </td> with <td> Level1 </td> Any ideas? the <td> author </td> is wrapped with other HTML element <td align="center"> <a onclick="return listItemTask('cb1','block')" href="javascript:void(0);"> ...

Help me with formatting a date

So I've got this: date('c') which formats it like so: 2010-08-17T08:55:14-07:00 but I need a way to not have the colon in the offset, so maybe it would look like this: 2010-08-17T08:55:14-0700 What solution is there for this? I'm hoping for a slightly different format, rather than getting the string and replacing the last colon (us...

Kohana3 ORM: loading Key/Value Attributes

I have two MySQL-Tables (oversimplified): articles - id - description article_attributes - article_id - attribute_name - attribute_value So, every article can have an unlimited amount of attributes. For the articles i have a Kohana_ORM Model <?php class Model_Article extends ORM {} ?> When loading the Model I would like to have ac...

Consuming object of ComplexType through PHP SoapClient

I'm trying to consume a soap feed using the PHP SoapClient and convert it to an array. It works great until I run into an object that is a complexType. Then it returns... [0] => stdClass Object ...instead of showing the multiple elements that are displayed when I access the SOAP feed otherwise. I'm very new to SOAP, so any help is ap...

Multi-line Links with preg_replace | PHP

If someone posts a multi-line post that contained text and links, I want to be able to find and wrap the links with <p> tags, but I can only do it with one link at a time (source code comes from phpBB2 - clickable links function), which causes every link to be like this: <p>http://www.bbc.co.uk/&lt;/p&gt; <p>http://www.bbc.co.uk/&lt;/p&...

Transfer PHP session to flash

Hello, we developed an internet application for company purposes a while back (company and friends, to be precise :]) and now we're trying transfer PHP session to loaded Flash, so flash can identify itself as being loaded with user profile (stored in MySQL, accessed only by PHP so far) when communicating with server (either FMS or Wowza...

recursive function php

I have an array which looks like this $dataArray = array ( 0 => array ( 'UserId' => '804023', 'ProjectCode' => 'RA1234', 'Role' => 'PI', ), 1 => array ( 'UserId' => '804023', 'ProjectCode' => 'RA1234', 'Role' => 'PM', ), 2 => array ( 'UserId' => '804023', 'ProjectCode' => 'A90123', ...

How to download multiple files from URL in PHP?

I have this array. $urls = array( '0'=>'http://www.domain.com/media1.mp3' '1'=>'http://www.domain.com/media2.mp3' '2'=>'http://www.domain.com/media3.mp3' ) I wan to download these files simultaneously with the help of PHP. How do I do that? Any suggestions? I have tried putting headers in for loop but what it does is it combines the...

PHP: Can an array have an array as a key in a key-value pair?

I'm getting an "Illegal offset type" for this array: public static $CATS_AND_TYPES = array( // Statement Administration array( self::CAT_STATEMENT_ADMIN => "Document Administration" ) => array( self::TYPE_STATEMENTS_LOADED => "Documents Loaded", self::TYPE_STATEMENTS_REMOVED => "Documents Removed...

Remove all but valid characters

Valid characters include the alphabet (abcd..), numbers (0123456789), spaces, ' and ". I need to strip any other characters than these from a string in PHP. Thanks :) ...

PHP/MySQL news archive

Hi, I'm a bit stuck trying to get my code to output correctly, see below. It all works ok, but rather than displaying all news items, it only shows one for each month. What I need to do is group all news for a selected month with the month/year heading for that month. Hope this makes sense. Any help greatly appreciated. SS $theQuery="...

Controller actions being called twice --- Php application

Hello, I'm new around so if I'm missing some info or something, please let me know and I'll provide it. I've already looked for informationg regarding this error, but I haven't found anything relevant yet. So, here's the deal.. Some of my controllers actions are being called twice, and I've just noticed that when I was wondering why was ...

Is it possible to send email attachments to a different address with PHP mail()?

My company email does not have much space so I want to forward attachments to a Gmail address. Is that possible? ...