Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. here you go,  :)

     

    $xml = "<?xml version='1.0' encoding='UTF-8'?>
    <feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='W/"CUAFSH47eCp7I2A9WhJQEE4."'>
    <entry gd:etag='W/"YDwqeyM."'>
    <media:group>
    <media:player url='https://www.youtube.com/watch?v=dCVmk66ldkE9w&feature=youtube_gdata_player'/></media:group>
    </entry>
    </feed>";
    
    $sxml = simplexml_load_string($xml);
    foreach ($sxml->entry as $entry) {
    // get video player URL
    $media = $entry->children('http://search.yahoo.com/mrss/');
    $attrs = $media->group->player->attributes();
    $watch = $attrs['url'];
    print $watch;
    }
    

     

    i loaded it from a string, but the principle is exactly the same. hope it helps. this returns : https://www.youtube.com/watch?v=dCVmk66ldkE9w&feature=youtube_gdata_player

  2. you are telling strtotime to select the fourth thursday AFTER the first thursday of the month, which is the 29th. you want it to say ' i want the date for the third thursaday after the first thu, so:

    echo strtotime("3 weeks thursday November 1 2012");
    

  3. //check the variable is being passed through
    if (isset($_POST['CSize'])){
    echo 'CSize is '.$_POST['CSize'];
    }
    
    // also your query should be quoted correctly
    $Get_Size_sql = "SELECT * FROM `csize` WHERE `Size` ='".$_POST["CSize"]."'";
    
    // try echoing out the whole query string aswell
    echo $Get_Size_sql ;
    

     

    and switch your error handling on

  4. there are a few choices available to you in the framework:

    1) create an aync / ajax controller :

     

    you can create an ajax conroller, and in the init method of the controller you disable the view from rendering using:

    public function init()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
    }

    then an example method you will call could be  /MyajaxController/getmyinfo/var1

     

    public function getmyinfoAction(){
    $result = (database array or whatever);//array - stuff from database
    echo json_encode($result);
    
    
    }
    

     

    2) read up on zend frameworks context switching. this is the preferable method, as you wont then need a specific ajax controller. the context switching allows you to use your normal controllers, and basically says ' if this call is ajax then return json etc......

  5. In addition to my original post, i have tried using an embedded recipeIngredient type in my form, but as expected ingredient_name is not part of recipeingredient so i get an error when submitting my form. What i really need is to have

    this as a collection in the form. So that i can have x amount of ingredients per recipe. Just lost as volume is stored in the join table and the ingredient name is in the ingredients table, which are 2 totally different entities

    volume | ingredient

    ------------------------

    1 tsp    | salt

    500 g  | flour .......

     

     

    anyone?

  6. Hi Guys, I have been having a play around with symfony 2 and doctrine, and everything was going fine until i hit a bit of a brick wall. As a test I am building a recipe blog and part of the design is causing me a headache. Basically i have made a three table relation : Recipe =>RecipeIngredients<=Ingredients.

    the recipe entity:

    <?php
    namespace Recipe\BlogBundle\Entity;
    use Doctrine\ORM\Mapping as ORM;
    use Doctrine\Common\Collections\ArrayCollection;
    /**
    * @ORM\Entity
    * @ORM\Table(name="recipe")
    * @ORM\HasLifecycleCallbacks()
    */
    class Recipe{
    
        /**
        * @ORM\Id
        * @ORM\Column(type="integer")
        * @ORM\GeneratedValue(strategy="AUTO")
        */
        protected $id;
    
        /**
         * @ORM\Column(type="string")
         */
        protected $recipeName;
    
        /**
         * @ORM\Column(type="text")
         */
        protected $recipeDescription;
    
        /**
         * @ORM\ManyToOne(targetEntity="RecipeCategory", inversedBy="recipe")
         * @ORM\JoinColumn(name="recipe_id", referencedColumnName="id")
         */
        protected $recipeCategory;
        
        /**
         * @ORM\OneToMany(targetEntity="Comment", mappedBy="recipe")
         */
        protected $comments;
    
        /**
         * @ORM\Column(type="datetime")
         */
        protected $created;
    
        /**
         * @ORM\OneToMany(targetEntity="RecipeSteps", mappedBy="recipe")
         */
        protected $recipeSteps;
        
        /**
         * @ORM\OneToMany(targetEntity="RecipeIngredients", mappedBy="ingredients", cascade={"all"})
         */
        protected $ingredients;
    
    
        /**
         * @ORM\Column(type="string")
         */
        protected $image;
    
         public function __construct()
        {
        $this->comments = new \Doctrine\Common\Collections\ArrayCollection();
        $this->recipeSteps = new \Doctrine\Common\Collections\ArrayCollection();
        $this->ingredients = new \Doctrine\Common\Collections\ArrayCollection();
        }
        
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
    
        /**
         * Set _recipeName
         *
         * @param string $recipeName
         */
        public function setRecipeName($recipeName)
        {
            $this->_recipeName = $recipeName;
        }
    
        /**
         * Get _recipeName
         *
         * @return string 
         */
        public function getRecipeName()
        {
            return $this->_recipeName;
        }
    
        /**
         * Set recipeDescription
         *
         * @param text $recipeDescription
         */
        public function setRecipeDescription($recipeDescription)
        {
            $this->recipeDescription = $recipeDescription;
        }
    
        /**
         * Get recipeDescription
         *
         * @return text 
         */
        public function getRecipeDescription()
        {
            return $this->recipeDescription;
        }
    
        /**
         * Set created
         *
         * @param datetime $created
         */
        public function setCreated($created)
        {
            $this->created = $created;
        }
    
        /**
         * Get created
         *
         * @return datetime 
         */
        public function getCreated()
        {
            return $this->created;
        }
    
        /**
         * Set image
         *
         * @param string $image
         */
        public function setImage($image)
        {
            $this->image = $image;
        }
    
        /**
         * Get image
         *
         * @return string 
         */
        public function getImage()
        {
            return $this->image;
        }
    
        /**
         * Set recipeCategory
         *
         * @param Recipe\BlogBundle\Entity\RecipeCategory $recipeCategory
         */
        public function setRecipeCategory(\Recipe\BlogBundle\Entity\RecipeCategory $recipeCategory)
        {
            $this->recipeCategory = $recipeCategory;
        }
    
        /**
         * Get recipeCategory
         *
         * @return Recipe\BlogBundle\Entity\RecipeCategory 
         */
        public function getRecipeCategory()
        {
            return $this->recipeCategory;
        }
    
        /**
         * Add comments
         *
         * @param Recipe\BlogBundle\Entity\Comment $comments
         */
        public function addComment(\Recipe\BlogBundle\Entity\Comment $comments)
        {
            $this->comments[] = $comments;
        }
    
        /**
         * Get comments
         *
         * @return Doctrine\Common\Collections\Collection 
         */
        public function getComments()
        {
            return $this->comments;
        }
    
        /**
         * Add recipeSteps
         *
         * @param Recipe\BlogBundle\Entity\RecipeSteps $recipeSteps
         */
        public function addRecipeSteps(\Recipe\BlogBundle\Entity\RecipeSteps $recipeSteps)
        {
            $this->recipeSteps[] = $recipeSteps;
        }
    
        /**
         * Get recipeSteps
         *
         * @return Doctrine\Common\Collections\Collection 
         */
        public function getRecipeSteps()
        {
            return $this->recipeSteps;
        }
    
        /**
         * Add ingredients
         *
         * @param Recipe\BlogBundle\Entity\RecipeIngredients $ingredients
         */
        public function addRecipeIngredients(\Recipe\BlogBundle\Entity\RecipeIngredients $ingredients)
        {
            $this->ingredients[] = $ingredients;
        }
    
        /**
         * Get ingredients
         *
         * @return Doctrine\Common\Collections\Collection 
         */
        public function getIngredients()
        {
            return $this->ingredients;
        }
    
    

    the ingredient entity:

    <?php
    namespace Recipe\BlogBundle\Entity;
    use Doctrine\ORM\Mapping as ORM;
    /**
    * @ORM\Entity
    * @ORM\Table(name="ingredients")
    */
    class Ingredients{
    
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;
    
        /**
         * @ORM\Column(type="string")
         */
        protected $ingredientName;
    
        /**
         * @ORM\OneToMany(targetEntity="RecipeIngredients", mappedBy="recipe", cascade={"all"})
         */
        protected $recipe;
       
        public function __construct()
        {
            $this->recipe = new \Doctrine\Common\Collections\ArrayCollection();
        }
        
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
    
        /**
         * Set ingredientName
         *
         * @param string $ingredientName
         */
        public function setIngredientName($ingredientName)
        {
            $this->ingredientName = $ingredientName;
        }
    
        /**
         * Get ingredientName
         *
         * @return string 
         */
        public function getIngredientName()
        {
            return $this->ingredientName;
        }
    
        /**
         * Add recipe
         *
         * @param Recipe\BlogBundle\Entity\RecipeIngredients $recipe
         */
        public function addRecipeIngredients(\Recipe\BlogBundle\Entity\RecipeIngredients $recipe)
        {
            $this->recipe[] = $recipe;
        }
    
        /**
         * Get recipe
         *
         * @return Doctrine\Common\Collections\Collection 
         */
        public function getRecipe()
        {
            return $this->recipe;
        }
    }

     

    and the association table:

    <?php
    namespace Recipe\BlogBundle\Entity;
    use Doctrine\ORM\Mapping as ORM;
    /**
    * @ORM\Entity
    * @ORM\Table(name="recipe_ingredients")
    */
    class RecipeIngredients{
    
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;
    
        /**
         * @ORM\Column(type="string")
         */
        protected $volume;
    
        /**
         * @ORM\ManyToOne(targetEntity="Ingredients", inversedBy="recipe", cascade={"all"})
         */
        protected $ingredients;
        
         /**
         * @ORM\ManyToOne(targetEntity="Recipe", inversedBy="ingredients", cascade={"all"})
         */
        protected $recipe;
    
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
    
        /**
         * Set volume
         *
         * @param string $volume
         */
        public function setVolume($volume)
        {
            $this->volume = $volume;
        }
    
        /**
         * Get volume
         *
         * @return string 
         */
        public function getVolume()
        {
            return $this->volume;
        }
    
        /**
         * Set ingredients
         *
         * @param Recipe\BlogBundle\Entity\Ingredients $ingredients
         */
        public function setIngredients(\Recipe\BlogBundle\Entity\Ingredients $ingredients)
        {
            $this->ingredients = $ingredients;
        }
    
        /**
         * Get ingredients
         *
         * @return Recipe\BlogBundle\Entity\Ingredients 
         */
        public function getIngredients()
        {
            return $this->ingredients;
        }
    
        /**
         * Set recipe
         *
         * @param Recipe\BlogBundle\Entity\Recipe $recipe
         */
        public function setRecipe(\Recipe\BlogBundle\Entity\Recipe $recipe)
        {
            $this->recipe = $recipe;
        }
    
        /**
         * Get recipe
         *
         * @return Recipe\BlogBundle\Entity\Recipe 
         */
        public function getRecipe()
        {
            return $this->recipe;
        }
    }
    

    So the issue i have been having is that i want to build a form to add a recipe, with the ability to add multiple ingredients at once and for each ingredient insert it into the ingredients table, and the volume for that ingredient into the recipeIngredient table. I am just struggling on how to build the form, and what' types' to use to do this in one go. I have been scratching my head for days on this . I hope this makes sense. Please help :)

  7. <?php
    session_start();
    include('php only scripts/db.php');
    $id = $_GET['id'];
    $query ="SELECT * FROM companies WHERE id = '$id'";
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result)){
                $websiteUrl = $row['website'].'?id='.$row['id'];
    			 echo $row['street1'] . 
    			"<br>" . $row['street2'] . 
    			"<br>" . $row['city'] . "," .  $row['postcode'] .  
    			"<br>phone: " . $row['phone'] .  
    			"<br>email: " . $row['email'] . 
    			"<br>website: <a href='$websiteUrl'>" . $row['website'].'</a>'  ; 
    }
    ?>
    

  8. you are echoing out the resource created from running the query. you need to actually fetch the records:

     

    $result = mysql_query("select PREF from  hist_index where DATE(PDATE) = DATE(NOW()) AND STKNO = 11");
    while($row = mysql_fetch_array($result)){
    echo $row['PREF];
    }
    

     

    hope it helps :)

  9. ok, you are going to need to debug line by line at this point to make sure the script is not dying. easiest, and quickest way, is to add a die statement into your php one line at a time.:

    die('i am here!!!!!);

    start at the top line of your function and move the die statment down a line each time until you dont se the i am here any more!!!. that will show you where your script is dying

  10. form didnt have name for register set, change form to this:

    <form action="" id="login" method="post">
                   <h1>Register</h1>
                   <fieldset id="inputs">
                   	<input autofocus id="first" name="first" placeholder="First Name" required type="text"/>
                        <input id="last" name="last" placeholder="Last Name" required type="text"/>
                        <input id="email" name="email" placeholder="someone@example.com" required type="email"/>
                        <input id="username" name="username" placeholder="Username" required type="text"/>
                        <input id="password" name="password" placeholder="Password" required type="password">
                        <input id="password" name="conf_pass" placeholder="Confirm Password" required type="password">
                   </fieldset>
                   <fieldset id="actions">
                        <input id="submit" type="submit" name="Register" value="Register">
                        <a href="">Forgot your password?</a><a href="login.php">Log In</a>
                   </fieldset>
              </form>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.