Jump to content


Photo

using print within an echo statement


  • Please log in to reply
4 replies to this topic

#1 sambib

sambib
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 March 2006 - 04:44 AM

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

<?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); ?>>

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......;)

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
    
}

thanks! :)

#2 Picatta

Picatta
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 28 March 2006 - 04:57 AM

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";

#3 sambib

sambib
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 March 2006 - 05:10 AM

[!--quoteo(post=359150:date=Mar 28 2006, 02:57 PM:name=Picatta)--][div class=\'quotetop\']QUOTE(Picatta @ Mar 28 2006, 02:57 PM) View Post[/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


#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 March 2006 - 05:19 AM

There's an echo inside the echo...
try this:
<?php
echo "<td><img src=\"rivcms/news/images/image_{$row['upload_id']}06.jpg\"" . imageResize($mysock[0], $mysock[1], 75) . "/>\n";
?>

Ken


#5 sambib

sambib
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 March 2006 - 05:22 AM

[!--quoteo(post=359159:date=Mar 28 2006, 03:19 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 28 2006, 03:19 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
There's an echo inside the echo...
try this:
<?php
echo "<td><img src=\"rivcms/news/images/image_{$row['upload_id']}06.jpg\"" . imageResize($mysock[0], $mysock[1], 75) . "/>\n";
?>

Ken
[/quote]

superb.......!

cheers fellas.......:)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users