nicedice Posted December 20, 2010 Share Posted December 20, 2010 Hi All - I'm relatively new to php but i do have a small amount of understanding about it, so please no complicated jargon coz my head will bleed! I have a php search getting specified info from a mysql db - when the data is returned it echo's out using this code: $results=array(); $sql=$queryCriteria; $result = mysql_query($sql,$link) or die('Error: ' . mysql_error()); while($a_row = mysql_fetch_array($result, MYSQL_ASSOC)) array_push($results, $a_row); if(count($results)){ //DISPLAY THE DATA foreach($results as $r){ echo(' <div class="post cut alignleft"> <div class="entry"> <div class="double alignleft"> <a href="images/propertypics/'.$r['image_1'].'" rel="gallery"> <img src="images/propertypics/'.$r['image_1'].'" alt="Pic" /></a> </div> <div class="sidebar alignright"> <h5>'.$r['address'].'</h5> <p>'.$r['summary'].'</p> <h5>£'.$r['price'].' pm</h5> <a class="morebutton moremd" href="property_lets.php?id='.$r['id'].'">More Info</a> </div> </div> </div> <br><br>'); } }else{ echo('Sorry - no results found'); } Now it works a treat but I need to add in an image resize function that exists on the website which uses this code: <?php $image = resize('your_image.jpg',array("w"=>600,"h"=>400)); ?> <img src="<?php echo $image; ?>" alt="Pic" /> I've tried various ways to shoehorn it in but with my limited php skills it's proving a pain. Any help would be much appreciated! Thanks in advance. Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted December 20, 2010 Share Posted December 20, 2010 Do you want the image physically changed in size or only changed in size for display purposes? if it is just for display purposes you could hard code it like this <img src="<?php echo $image; ?>" alt="Pic" width="600" /> it will auto scale the height to suit the image or you could set that aswell if you wanted to Quote Link to comment Share on other sites More sharing options...
nicedice Posted December 20, 2010 Author Share Posted December 20, 2010 hi - thanks for the reply. I guess just for display purposes - i already have a php function to change on the fly, it's just adding it to the first chunk of code supplied that I can't seem to do. Cheers. Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted December 20, 2010 Share Posted December 20, 2010 can just change this bit <img src="images/propertypics/'.$r['image_1'].'" alt="Pic" /> to <img src="images/propertypics/'.$r['image_1'].'" alt="Pic" width="600" /> and voila you dont need the resize bit Quote Link to comment Share on other sites More sharing options...
nicedice Posted December 20, 2010 Author Share Posted December 20, 2010 hi Dragon_sa - that's worked!! Your a star! Thanks for the quick replys Until next time (about 10 minutes the way i hit problems!) D Quote Link to comment Share on other sites More sharing options...
litebearer Posted December 20, 2010 Share Posted December 20, 2010 as an aside, if you are displaying images MANY times (the same one or different ones), that method while it will work for your visual purposes, results in increased load time as the the large image is being loaded, just displayed smaller. You might consider having a thumb version of your images to cut down on load times. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.