Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

imagettftext multiple images at same time, no saving but direct output?

  • 01-10-2012 02:31AM
    #1
    Registered Users, Registered Users 2 Posts: 3,512 ✭✭✭


    Hey, I am doing small quick project in college, so the story is as follows:
    I have database with like reminders table.
    I want it to select all records for specific user (no problem with that) and output all records into sticky notes.
    It works just fine but I just can't get seperate note/sticky for each entry, script stops at first row and I end up having just 1 image.
    Codes are as follows:
    <?php
    header('Content-Type: image/png');
    function GenerateNote($title, $deadline, $text, $priority, $name, $date){
        $image = "../images/stick".rand(1, 8).".png";
        $titlefont = "../ThrowMyHandsUpintheAirBold.ttf";
        $textfont = "../ThrowMyHandsUpintheAir.ttf";
        $t = substr($title, 0, 10);
        $dline = "Deadline: ".$deadline;
        $tex = wordwrap(substr($text, 0, 90), 20, "\n", true);
        $pr = $priority;
        $curdate = "Added: ".$date;
        $name = imagecreatefrompng($image);
        imagealphablending($name, true);
        imagesavealpha($name, true);
        $color = imagecolorallocate($name, 0, 0, 0);
        imagettftext($name, 30, 0, 80, 210, $color, $titlefont, $t);
        imagettftext($name, 20, 0, 80, 165, $color, $titlefont, $dline);
        imagettftext($name, 15, 3, 80, 250, $color, $textfont, $tex);
        imagettftext($name, 20, 3,90, 400, $color, $textfont, $curdate);
        imagettftext($name, 25, 3,95, 430, $color, $titlefont, $pr);
        imagepng($name);
    }
    include 'sql_connection.php';
    $getList = mysql_query("SELECT * FROM reminders WHERE user=0");
    while($data = mysql_fetch_assoc($getList)){
        GenerateNote($data['title'], $data['deadline'], $data['text'], $data['priority'], $data['id'], $data['date']);    
    }
    ?>
    
    
    

    DB queries are done successfully, I tested by echo'ing them. It gives out just 1 image like this:
    Untitled-1_zps8ecdd0d3.jpg

    Oh and by the way, if I try and put
    include 'sql_connection.php';
    $getList = mysql_query("SELECT * FROM reminders WHERE user=0");
    while($data = mysql_fetch_assoc($getList)){
        GenerateNote($data['title'], $data['deadline'], $data['text'], $data['priority'], $data['id'], $data['date']);    
    }
    

    in other file, and include this code file, it doesn't work for some reason. But anyways how do I make it output all images?

    $name is so that every name is different, it takes reminder entry id as name.
    Help?
    I just want all sticky notes to print across page (I will make script later so it randomly spreads them around, but for now I need to sort out this thing.)


Comments

  • Registered Users, Registered Users 2 Posts: 3,512 ✭✭✭arleitiss


    crap, sorry just realized wrong section, please move to Development


Advertisement