Get Method and Array Manipulation In Symfony

This Tutorial Has Been Viewed 1,238 Times.

Below is the action.class.php code for the success page named playlistSuccess.php,

here i am getting the values of mob0,mob1 etc., to mob7 from the address bar of browser that is we

are using the get method.The browser address bar contains something like this
http://localhost/frontend_dev.php/playlist/playlist?mob0=8761&mob1=8763&mob2=8764&mob3=8765&mob4=8773&mob5=8774&=8775&mob7=8901 From the code below i am getting all the values from the browser address bar and all of them are inserted in to an array named DATA.Then using FOREACH i just extracted the values and using the criteria i connected the database to the field name FILE where ID is the value that i get from the DATA array.The OUT variable has all the values we want and from that using FOREACH i once again extracted the correct values of each array in to MYDATA.This MYDATA has values of different fields of the TABLE FILE.

Then all the data that i want is now in the RESULTARRAY.


public function executePlaylist()

{

$this->a =$this->getRequestParameter('mob0');

$this->b =$this->getRequestParameter('mob1');

$this->c =$this->getRequestParameter('mob2');

$this->d =$this->getRequestParameter('mob3');

$this->e =$this->getRequestParameter('mob4');

$this->f =$this->getRequestParameter('mob5');

$this->g =$this->getRequestParameter('mob6');

$this->h =$this->getRequestParameter('mob7');

$data=array("$this->a", "$this->b", "$this->c", "$this->d", "$this->e" , "$this->f" ,"$this->g" , "$this->h");

$resultArray = array();

//print_r($data);

foreach($data as $val)
{

$cr = new Criteria();

$cr->add(FilePeer::ID,$val);

$this->out = FilePeer::doSelect($cr);
//another criteria
//echo $val;
foreach($this->out as $mydata){
// echo '<br />'.$mydata->getUserid();
// echo '<br />'.$mydata->getId();
//echo '<br />'.$mydata->getOrginalpath();
//echo '<br />'.$mydata->getCaption();
$resultArray[]=array( $mydata->getUserid(), $mydata->getId(), $mydata->getOrginalpath(), $mydata->getCaption(), $mydata->getDate());

}
}

$this->resultArray = $resultArray;
}

In the playlistSuccess.php page i am just outputting an XML file which i want to connect dynamically to my AUDIO PLAYER(THIS IS MY REQUIREMENT YOU CAN OUTPUT TO ANY XML FORMAT YOU WANT).

< ?php
echo '<?xml version=\"1.0\" encoding=\"UTF-8\" ?><songs>';foreach ($resultArray as $result){
$id = $result[0];
$mainid = $result[1];$title = $result[2];

$author = $result[3];
$date =$result[4];

$comma= '"';

echo "<song path=".$comma."$title".$comma. " bild=".$comma."http://s3.amazonaws.com/tutorialz/100×100/$id".$comma." artist=".$comma."$id".$comma." title=".$comma." $author".$comma."/>\r\n";

}

echo "</songs>";
?>
VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Incoming search terms:





You will also be interested in ,

Tags: , , ,

Leave a Reply

Spam protection by WP Captcha-Free

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks