Jump to content

Recommended Posts

I've got a function which uses gd2 to resize an image and I know it works within an HTML page:

[code]<?php

//get the image size of the picture and load it into an array
$mysock = getimagesize("images/image001.jpg");

?>

<!-using a standard html image tag, where you would have the  width and height, insert your new imageResize() function with  the correct attributes -->

<img src="images/image001.jpg" <?php print imageResize($mysock[0],  $mysock[1], 150); ?>>[/code]

HOWEVER, I get my images from a database and populate the page using some php and I don't know how to use the print function in this scenario (within the echo statement). the php is below the important bit is the WHAT DO I DO HERE bit......;)

[code]echo "<table class=\"table_test\">\n";
        
    }//end of first if
    
    //Display each record
        echo "<tr>\n";
        
        //get the image size of the picture and load it into an array
            $mysock = getimagesize("rivcms/news/images/image_{$row['upload_id']}06.jpg");
            //display the resized image on the screen.
            echo "<td><img src=\"rivcms/news/images/image_{$row['upload_id']}06.jpg\" WHAT DO I DO HERE imageResize($mysock[0], $mysock[1], 75) />\n";

        
        echo "<td>{$row['t']}</td>\n";
        echo "<td>{$row['d']}</td>\n";
        echo "</tr>\n";
    
    $first = FALSE; //One record has been returned
    
}[/code]

thanks! :)
Link to comment
https://forums.phpfreaks.com/topic/5985-using-print-within-an-echo-statement/
Share on other sites

[!--quoteo(post=359150:date=Mar 28 2006, 02:57 PM:name=Picatta)--][div class=\'quotetop\']QUOTE(Picatta @ Mar 28 2006, 02:57 PM) [snapback]359150[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Short answer: You can't.

Long Answer: You can just use the period on connect the echo and print commands, like this:

echo "<td><img src=\"rivcms/news/images/image_{$row['upload_id']}06.jpg\"" . imageResize($mysock[0], $mysock[1], 75) echo "/>\n";
[/quote]

sorry no go, copy and pasted that but got an error:

Parse error: parse error, unexpected T_ECHO, expecting ',' or ';' in D:\Apache\htdocs\riverview\n_latest_test.php on line 58
[!--quoteo(post=359159:date=Mar 28 2006, 03:19 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 28 2006, 03:19 PM) [snapback]359159[/snapback][/div][div class=\'quotemain\'][!--quotec--]
There's an echo inside the echo...
try this:
[code]<?php
echo "<td><img src=\"rivcms/news/images/image_{$row['upload_id']}06.jpg\"" . imageResize($mysock[0], $mysock[1], 75) . "/>\n";
?>[/code]

Ken
[/quote]

superb.......!

cheers fellas.......:)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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