Jump to content

harristweed

Members
  • Posts

    346
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by harristweed

  1. you need to 'sort out' your xml first....

    <?php
    $string="
    <document>
    <entry>
       <id>1234</id>
       <name>Name</name>
       <age>Age</age>
    </entry>
    <entry>
       <id>1234</id>
       <name>Name</name>
       <age>Age</age>
    </entry>
    <entry>
       <id>1234</id>
       <name>Name</name>
       <age>Age</age>
    </entry>
    <entry>
       <id>1234</id>
       <name>Name</name>
       <age>Age</age>
    </entry>
    </document>
    ";
    
    
    if(!$xml = simplexml_load_string($string)){
        $message.="Can't connect to xml";
        }else{
            $count=1;
    foreach ($xml->entry as $value){
            $GLOBALS['Entry'.$count]=$value->id;
            echo $GLOBALS['Entry'.$count]."<br />\n";
            $count++; 
             $GLOBALS['Entry'.$count]=$value->name;
            echo $GLOBALS['Entry'.$count]."<br />\n";
            $count++;          
            $GLOBALS['Entry'.$count]=$value->age;
            echo $GLOBALS['Entry'.$count]."<br />\n";
            $count++; 
            }
        }
    ?>

  2. if($current_level_id != $data['level_id']) 
            {
                $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5);
                $current_level_id = $data['level_id'];
                $subject_data = array();
            }

     

    The array $subject_data will be initialised  every loop!. So will only contain the last entry. Move outside the loop!

    $subject_data = array();
    while($data = mysqli_fetch_array($sql)) 
        {
            if($current_level_id != $data['level_id']) 
            {
                $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5);
                $current_level_id = $data['level_id'];
                
            }
            //Add the current record to the $level_data array
            $subject_data[] = $data;
        }

  3. Try

    $query = ' SELECT p.*,c.name as name_category,t.name as name_type,cy.name as name_country,s.name as name_state,l.name as name_locality,pf.name as name_profile,pf.logo_image as logo_image_profile, '
    . ' CASE WHEN CHAR_LENGTH(p.alias) THEN CONCAT_WS(":", p.id, p.alias) ELSE p.id END as Pslug,'
    . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as Cslug,'
    . ' CASE WHEN CHAR_LENGTH(cy.alias) THEN CONCAT_WS(":", cy.id, cy.alias) ELSE cy.id END as CYslug,'
    . ' CASE WHEN CHAR_LENGTH(s.alias) THEN CONCAT_WS(":", s.id, s.alias) ELSE s.id END as Sslug,'
    . ' CASE WHEN CHAR_LENGTH(l.alias) THEN CONCAT_WS(":", l.id, l.alias) ELSE l.id END as Lslug, '
    . ' CASE WHEN CHAR_LENGTH(t.alias) THEN CONCAT_WS(":", t.id, t.alias) ELSE t.id END as Tslug '
    . ' FROM #__properties_products AS p '
    . ' LEFT JOIN #__properties_country AS cy ON cy.id = p.cyid '
    . ' LEFT JOIN #__properties_state AS s ON s.id = p.sid '
    . ' LEFT JOIN #__properties_locality AS l ON l.id = p.lid '
    . ' LEFT JOIN #__properties_profiles AS pf ON pf.mid = p.agent_id '
    . ' LEFT JOIN #__properties_category AS c ON c.id = p.cid '
    . ' LEFT JOIN #__properties_type AS t ON t.id = p.type '
    . ' WHERE p.published = 1 '
    .' ORDER BY p.id DESC'  'LIMIT 0, 200 '
    ;

  4. I have done something similar in the past, here is my code, you should be able to amend it to suit....

    $size = GetImageSize ("$path_to_image");   // set image name here
        $old_width = $size[0];
        $old_height = $size[1];
    
        if($old_width/$old_height < 1.33334){//is it landscape or portrate?
            $new_height=300;
            $new_width=round($old_width/$old_height*300);
        }else{
        $new_width = $width;
        $new_height = round($old_height * $width / $old_width);  
        }
    
        $source_path=$where_temp;   //Source File path
        $destimg=imagecreatetruecolor($new_width,$new_height) or die("<p>Problem In Creating image</p>");
    
        $srcimg=ImageCreateFromJPEG($source_path.$image_name) or die("<p>Problem In opening Source Image</p>");
        // imagecopyresampled for better quality
        imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("<p>Problem In resizing</p>");
        //create an image 400x300
        $base=imagecreatetruecolor(400,300);
        
        $white= imagecolorallocate($base,208,244,255);
        //make white background
        imagefill($base,0,0, $white);
        //calculate the starting x position to place image in center of background
        $xpos=round((400-$new_width)/2);
        //merge the two images
        imagecopy($base,$destimg,$xpos,0,0,0,$new_width,$new_height);
        
        ImageJPEG($base,$destination_path.$image_name) or die("<p>Problem In saving</p>");
    }

  5. What I do may give you some ideas, I have a function that send me an email...

    function problem($message){
    $today = date('Y-m-d H:i:s');
    $mail_message =  $message;
    $mail_message.="<br /><br />at: $today";
    $subject = "Problem on [name of site] Website";    
    $headers .= "From: info@[domain name]\n";
    $headers .= "X-Priority: 2\n";
    $headers .= "MIME-Version: 1.0\n"; 
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n";
    $email = "me@mydomain.com";
    
    if(mail($email, $subject, $mail_message, $headers));
        return;
    } //end of email

     

    then I have this in all mysql queries:

    if(!mysql_query($sql)){
        $err=mysql_error();
        problem("page name.php - line number XX
        <br /><br />
        $err<br /><br />
        $insert");

     

×
×
  • 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.