Jump to content

marknt

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Posts posted by marknt

  1. Hello guys, I'm using symfony framework. How can I access the 'table2.fieldname' in my indexSuccess.php? I can't figure out how to use the getSfGuardUser() function. Maybe there's a way to access the 'table2.fieldname'?

     

    I have been searching the online doc but to no luck I couldn't find the solution I'm looking for.

     

    SQL Query

    SELECT gi.title, up.first_name, up.last_name, t.shirt_image
    FROM game_image gi
    LEFT JOIN user_profile up ON up.user_id = gi.user_id 
    LEFT JOIN team t ON t.team_id = up.team_id 
    

     

    action.class.php

    <?php
    $pager = new sfPropelPager('GameImage', ;
    $c = new Criteria();
    $c->addJoin(GameImagePeer::USER_ID, UserProfilePeer::USER_ID, Criteria::LEFT_JOIN);
    $c->addJoin(UserProfilePeer::TEAM_ID, TeamPeer::TEAM_ID, Criteria::LEFT_JOIN);
    
    $pager->setCriteria($c);
    $pager->setPage($this->getRequestParameter('page', 1));
    $pager->setPeerMethod('doSelect');
    $pager->init();
    $this->pager = $pager;
    ?>
    

     

    indexSuccess.php

    <?php foreach($pager->getResults() as $thumb){ ?>
        <?php echo $thumb->getTitle(); // table1 fieldname ?>
        <?php echo $thumb->getSfGuardUser()->getUserProfile()->getFirstName(); // table2 fieldname ?>
    <?php } ?>
    

     

    It returns an error

    Fatal error: Call to a member function getUserProfile() on a non-object in indexSuccess.php
    

     

    How can I solve this problem?  :'(

     

    Thanks in advance.

  2. this is a test sample code. My real code is CI MVC with lots of models.

     

    <?php
    function rec_in_array($needle, $haystack, $alsokeys=false)
    {
        if(!is_array($haystack)) return false;
        if(in_array($needle, $haystack) || ($alsokeys && in_array($needle, array_keys($haystack)) )) return true;
        else {
            foreach($haystack AS $element) {
                $ret = rec_in_array($needle, $element, $alsokeys);
            }
        }
       
        return $ret;
    }
    
    $array = array(
    0 => 'blue', 
    1 => 'red', 
    2 => 'green', 
    3 => 'red',
    4 => array("sub1", "sub2")
    );
    
    $key = array_search('green', $array); // $key = 2;
    $key = array_search('red', $array);   // $key = 1;
    $yo = array_search('sub1', $array);   
    
    echo "<br><b>dito = $yo</b><br>";
    
    $key = rec_in_array('sub2', $array);
    print_r(array_keys($array));
    
    echo "<pre>"; print_r($array); echo "</pre>";
    echo "<br>" . $key . "<hr color=green>";
    ?>
    

  3. Hi guys I need your help.

     

    Guys I have this print_r array

    Code:

     

    <?

    [2] => Array

            (

                [ 0 ] => Array

                    (

                        [_parent_name] => User_model

                        [user_code] => jdelacruz

    ?>

     

    The [2] there is the main array key and I used a function to search the jdelacruz value. So the function will return true but I need to find the array key which is [2] and store it in a variable. How can I do that?

     

    Any suggestions?

     

    Thanks in advance  ;)

  4. Hello guys. I'm doing a report and already used the window.print() javascript function. But at the upper right of the page appears the URL of the php file to print and at the lower left is the page number. I want to disable them. I have checked the page setup in firefox and you can disable it manually.

     

    My question is is there anyway i can access the page setup via PHP so that i can disable the added URL and page numbering in my page when i print it out?

     

    Thanks in advance! More power  :)

  5. Ok, I this is my code that Translates server time into client localized time based on client's chosen offset. And it works.
    [code]
    <?php
    define('TIMENOW',time());
    function translate_time($_offset,$_time = TIMENOW)
    {
    $_offset_secs = $_offset * 3600;
    return $_offset_secs + $_time;
    }

    $model_timeoffset = -3;
    $clients_time = $admin->translate_time($model_timeoffset,TIMENOW);
    $servers_time = date("F d, Y l g:i A");
    $gmt_time = ?
    ?>
    [/code]

    How can I convert the client's time to the current GMT time? Thanks

    Cheers
    [img]http://i91.photobucket.com/albums/k310/marknt/36_1_211.gif[/img]
  6. [quote author=heckenschutze link=topic=114369.msg466406#msg466406 date=1163230963]
    The image is still going to have the same size, byte wise...

    Not sure that's what he's after. :)
    [/quote]
    Yes you are correct. Same size but in thumbnail view. For example resize it by minus 25% but same size
  7. [code]
    <?php
    function imageResize($width, $height, $target) {

    if ($width > $height) {
    $percentage = ($target / $width);
    } else {
    $percentage = ($target / $height);
    }

    //gets the new value and applies the percentage, then rounds the value
    $width = round($width * $percentage);
    $height = round($height * $percentage);

    //returns the new sizes in html image tag format...this is so you
    //can plug this function inside an image tag and just get the
    return "width=\"$width\" height=\"$height\"";
    }
    $pic = "./images/picture.jpg";
    $mysock = getimagesize($pic);
    $var = imageResize($mysock[0], $mysock[1], 150);
    ?>

    <img src="<?=$pic?>" <?=$var?>>
    [/code]

    It worked for me promise. It feels good to help someone. I have learned the hard way when I'm still starting as a PHP Developer.
  8. [quote author=heckenschutze link=topic=114610.msg466385#msg466385 date=1163226540]
    Its in the php configuration file,

    So you can edit it directly from php.ini OR at runtime using ini_set()

    Example:
    [code]
    ini_set("session.cookie.lifetime", 360000);
    ?>
    [/code]

    hth!

    [/quote]
    Hello heckenschutze. How can i set the session lifetime via ini_set? I don't want to edit my php.ini settings
  9. Hello people, im sorry but i dunno if this is the right place to post this question.

    Anyway i have already assigned a smarty variable and it appeared to my first tpl file. My problem is how can i pass my smarty variables to my second tpl file?

    In my first tpl file i have a button there:
    [code]
    <input class="button" type="button" value="EDIT SCHEDULE" name="submit_edit"
        onclick="location.href='http://dev.hotcamsluts.com/modelcp/edit_schedule.php';this.value='E D I T I N G . . . .'">
    [/code]

    So if it is clicked it will go to another php file and generate the second tpl file. I want to pass my variables in my first tpl file to my second tpl file. How can i do that? Help. Thanks

    Cheers  :)
  10. Hello sir alpine. I think i solved my own problem *sigh*  :D

    I think im just lucky  ;D

    Here is my code:
    [code]

    // this is a string
    $mytime = "11:30 PM";
    // Converting string time ( 11:30 PM ) to Military time (23:30)
    $temp = strtotime("$mytime");
    $military_time = date('H:i', $temp);

    echo "String Time: $mytime<br>";
    echo "Temp: $temp<br>";
    echo "Military time: $military_time<br>";

    [/code]

    Thank you for replying Sir Alpine.
    Cheers
  11. Hello people i need some help. Im figuring this out.

    I have a variable $var="11 PM". I want to convert it into military time like this one ---> 23

    here is my code but its not working:

    [code]
    $var = "10"; // this is equivalent to 10 PM

    $military_time = date('H', $var);
    echo "Hour: $var<br>";
    echo "Military time: $military_time<br>";
    [/code]

    Please help thanks a lot!
    Cheers
  12. [quote author=alexcrosson link=topic=110197.msg444987#msg444987 date=1159756805]
    THis is the error i get
    [b]
    Parse error: parse error, unexpected T_WHILE in /home/totallyc/public_html/login/blog.php on line 37[/b]

    Line 37 is : [quote]while($row=mysql_fetch_array($result)) {[/quote]
    [/quote]
    i may add
    [code]while($row=mysql_fetch_array($result, MYSQL_BOTH))[/code]
×
×
  • 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.