php

Best way to link multiple items to individual ones in MySQL

I'm making a site with PHP and MySQL. The big idea is that you can register and you can add objects to your profile. You can have only 1 profile, you can have multiple items(infinite, in theory) and each items can have multiple pictures(infinite, in theory). I'm wondering how to best implement this in MySQL. I've had a very basic educat...

Howto merge into a database

I am having trouble figuring out the best way to approach this problem, I have two different list of items, one in the DB, one not. Both list have item ids and quantity, I need to merge the two list into the DB. My first inclination is to just pull all of the items out of the DB then merge the two list in the application logi...

Zend Framework Grid

Can anyone recommend a good Zend Framework friendly table/grid API? I'm developing an information management system and I need a component where I can display all/some of the records, and provide paging, search, sorting, and link to various actions. I've been looking into Dojo with (dojox.grid.Grid) and it just doesn't feel right to me...

Find which two values of an array a given value is between

Suppose I have an array similar to this (actual values probably will not be so predictable): $ar[0] = 5; $ar[1] = 10; $ar[2] = 15; $ar[3] = 20; and I have $n = 8, what would be a good way to find that $n falls between $ar[0] and $ar[1]? Preferably, the solution would avoid looping through the entire array, as this will probably repeat...

Best practices on displaying search results with associated text snippets from actual result

I have a decent, lightweight search engine working for one of my sites using MySQL fulltext indexes and php to parse the results. Work fine but I'd like to offer more 'google-like' results with text snippets from the results and the found words highlighted. Looking for a php based solution. Any recommendations? ...

reading two rss/xml files in a single php page

I have a script where i need to pull two seperate and different RSS feeds, break them up, assign variables, and execute code thats different for each file. What im wondering, and i dont know if this can even be done, but once i use a function and give it settings, can i then re-use that function with different settings even though some ...

Built-in PHP function to reset the indexes of an array?

Example: $arr = array(1 => 'Foo', 5 => 'Bar', 6 => 'Foobar'); /*... do some function so $arr now equals: array(0 => 'Foo', 1 => 'Bar', 2 => 'Foobar'); */ ...

SOAP PHP Parsing Error?

I'm communicating with a SOAP service created with EJB -- it intermittently fails, and I've found a case where I can reliably reproduce. I'm getting a funky ass SOAP fault that says "looks like we got not XML," however, when retrieving the last response I get what is listed below (and what looks like valid XML to me). Any thoughts? ...

In php how can I make sure that static variables declared in a function will not re-initiated whenever the function is called?

It seems that a static variable declared in a function is re-initiated whenever the function is called, how can I use the function in a way that re-calling the function will re-use the static parameter? I defined the function 'testStatic' in static.php here is static.php: <?php function testStatic() { static $staticV = 0; echo...

Parsing JSON from PHP

Hi, I'm trying to iterate in a JSON object that is returned from a PHP script. The return part is something like: $json = array("result" => -1, "errors" => array( "error1" => array("name" => "email","value" => "err1"), "error2" => array("name" => "pass","value" => "err2") ) ); $encoded = json_encode($json...

How can I make visual studio highlight .php files

Hope the title explains it all, but all I'm trying to do is open some .php files in my web-site solution and have Visual studio treat them as if they are html files. I don't need the actual PHJP code highlighted (it's only includes). The HTML syntax should be parse-able, should it not? ...

PHP tutorials/guides that influenced you or improved your code

What tutorials or guides about features/techniques influenced the way you did something. Eg a compelling tutorial (located here) about unit testing got you into unit testing. Your code improved dramatically. ...

Finding a point in a string that is not inside BBCodes.

Hi, I have a string which contains the text of an article. This is sprinkled with BBCodes (between square brackets). I need to be able to grab the first say, 200 characters of an article without cutting it off in the middle of a bbcode. So I need an index where it is safe to cut it off. This will give me the article summary. The summa...

Using regular expressions to extract the first image source from html codes?

Hello, I would like to know how this can be achieved. Assume: That there's a lot of html code containing tables, divs, images, etc. Problem: How can I get matches of all occurances. More over, to be specific, how can I get the img tag source (src = ?). example: <img src="http://example.com/g.jpg" alt="" /> How can I print out ht...

Is there a way to transfer/translate the code written in Java to other languages?

Theoretically this seems possible to me. So can Any one confirm this to me, if it's possible? and if there is such a software that does this?(like Java to C++ or C#) And in general would it be possible to transfer languages like Java to server-side programing language like PHP? ...

Drupal: Accessing all rows in a view as an array

Apologies for the awkward wording in this question; I'm still trying to wrap my head around the beast that is Drupal and haven't quite gotten the vocabulary down yet. I'm looking to access all rows in a view as an array (so I can apply some array sorting and grouping functions before display) in a display output? The best I can tell, yo...

WMD markdown editor - HTML to Markdown conversion

I am using wmd markdown editor on a project and had a question: When I post the form containing the markdown text area, it (as expected) posts html to the server. However, say upon server-side validation something fails and I need to send the user back to edit their entry, is there anyway to refill the textarea with just the markdown a...

Passing data from one php page to another is not working - why????

Hi all - Frustrated php novice here... I'm trying to pass a "type" value of either billto or shipto from ab.php to abp.php. ab.php snippet: <?php echo '<a href="' . tep_href_link(FILENAME_ABP, 'edit=' . $bill_address['address_book_id'] . '&type=billto', 'SSL') . '">' . tep_image_button('small_edit.gif', SMALL_IMAGE_BUTTON_EDIT) ....

Can I save a very large array of userID's to a session variable for multiple users?

OK I have a social network, around 50,000 users so far and there is a friend table that show who is your friend on the site, this table is over a million rows Not the tricky part, I show user posted bulletin, status posts, stuff like that that is only visible to people on your friend list. Keep in mind the size of the tables, user table...

In PHP what is the right approach for loading configuration parameters into application variables?

I have a database where I keep my configuration parameters, I want to load the configuration parameters into my application variables only once (or upon specific request to reload the parameters), I also want these variables which holds the configuration parameters to be accessible from all php pages/scripts, the idea is to save hits on ...