Jump to content

Archived

This topic is now archived and is closed to further replies.

sambib

using print within an echo statement

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! :)

Share this post


Link to post
Share on other sites
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";

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[!--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.......:)

Share this post


Link to post
Share on other sites

×

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.