php

Getting the last 7 rows from MySQL in PHP

I'm trying to get the last 7 records from a table whose records were entered by the user Here is my query: $database->setQuery("SELECT * FROM #__mytable WHERE (user_id = '$uid')"); $dberr=""; if (!$database->query()) { $dberr = $database->getErrorMsg(); } if(!$dberr==""){ echo($dberr."<br>"); }else{ $rows = $database->loadOb...

PHP - foreach affects session value

How can foreach loop affect session variable? session_start(); $_SESSION[test] = "Session content"; echo $_SESSION[test].'<br />'; $test_array = array("test", "array", "something", "array end"); foreach($test_array as $test){ echo $test.'<br />'; } echo '<br />Session content after foreach: '.$_SESSION[test].'<br />'; When I ru...

jQuery generated input fields: read form values in php?

Hello, I'm getting a json string with jQuery and then for each value, I add a checkbox. function dateClick(url){ $.getJSON(url, function(data){ var row = $("#HourSelectionTable tbody").html(); $("#HourSelectionTable").empty(); $("#HourSelectionTable").append(row); $.each(data, function(i,data){ ...

Problem sending additional post data to server with uploadify

Hello there, I'm using uploadify on a page that allows a user to upload images as well as a category field in which to send those images. Now, I see that uploadify provides a "scriptData" method that allows me to send over key value pairs to the uploadify.php script. But the problem is that the scriptData method grabs its values upon pa...

What does a Data Mapper typically look like?

I have a table called Cat, and an PHP class called Cat. Now I want to make a CatDataMapper class, so that Cat extends CatDataMapper. I want that Data Mapper class to provide basic functionality for doing ORM, and for creating, editing and deleting Cat. For that purpose, maybe someone who knows this pattern very well could give me some ...

Resume Facebook Connect session from iPhone on server

Hello, I have an iPhone app which creates a facebook session and I would like to restore this session on my server to hand off some of the work. I have the iPhone app working perfectly fine, it's just that I am having problems restoring the session - the documentation is lacking, at best (from http://wiki.developers.facebook.com/index....

Store html entities in database? Or convert when retrieved?

Quick question, is it a better idea to call htmlentities() (or htmlspecialchars()) before or after inserting data into the database? Before: The new longer string will cause me to have to change the database to hold longer values in the field. (maxlength="800" could change to a 804 char string) After: This will require a lot more serve...

Built-in method for finding a specific instance of an object in PHP?

I really am clueless when it comes to object-oriented programmings, so forgive me if this is obvious... I am using a Zend extension which returns a request as a nested object. I need property a based on if the object has property b. Right now I am using a foreach loop with a conditional to search for property b and, if I get a match, se...

Problem encrypting/encoding URL variable

I have a class that takes a string in this format: 000067000000000012620060324b38e2cab3353 , encrypts the string then appends it as a get variable in a URL. The class that does the encryption has a function that looks like this: private function _code_encryption($enc_type,$a_string){ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJND...

Joomla Login Redirect

How can you specify which page the user lands after they have logged into a Joomla site? ...

How to handle mass email

Hi there, I'm about ready to unveil a "coming soon" page and one thing I need is a way for users to enter their email address for me to email once the site goes live. What is the best way to do this? Should I store the emails in a DB and then run a PHP script to email them from my web host? Should I have the emails just kind of be coll...

MySQL Benchmark

Hi Everyone, I am trying to use MySQL benchmark to test some queries. But, I am running to an error. SELECT benchmark (10000, (select title from user)); and in return I get this error; ERROR 1242 (21000): Subquery returns more than 1 row Does anyone know how to benchmark a query? Thanks ...

How can I use Zend Paginator and Zend Amazon together?

Is there a straightforward (easy) way to use Zend Framework's Paginator with the Zend Framework Amazon service? It looks like the recordset returned by the Amazon service is not what the Paginator needs. ...

getting total no of viewers in php

Im developing a site, i want to know how can i track who has viewed the profile of particular users, registered users or visiters. Site is developed in php. Any sugesstion please. ...

Magento - Removing Active State From Home Page

I have this code in top.phtml which displays my menu items in my Magento store: <div class="header-nav-container"> <div class="header-nav"> <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4> <ul id="nav"> <li <?php if(!Mage::registry('current_category')) { echo 'class="level0 active"'; } else { echo 'class="...

PHP: Trying to pull all values out of a multidimensional (recursive) array

Hi, I am trying to create a single array that contains all of the values of an existing multidimensional array. This is what I have so far... function MaxArray($arr) { foreach ($arr as $value) { if (is_array($value)) { MaxArray($value); } else { $array[] = $value; } } print...

PHP: Data from cURL, HTML Scan

How can i scan a html page, for text within a certain div? ...

initialize an array with dummy values

while ($row = mysql_fetch_object($result)) { $data[] = $row; echo "<div id='captionbox' style='width: 110px;float:left;color:#FFF;text-align:center;'>"; echo "<a href='#' class='thumb'><img class='thumb-img' value = ".$row->aid." onclick='getVote(".$row->aid.", \"".$row->atitle."\")' src='images/roadies/th".$row->aid.".j...

Magento Store - Best Selling items by Category

I'm using this code to create a list of best selling items in Magento: http://bit.ly/6rzMXf Does anyone know how this could be edited so it would show best selling items from a specific category? Thanks! ...

PHP Login Redirects

This is maybe a stupid question, but I figured I'd ask before I did something goofy: I've got an web application with a custom Login dialog which takes a user/pass that gets sent to the server. If both match an entry in the database, then there is maybe 10 or so pages that the user gets access to (depending on the rights associated with ...