Hi there, I need to make an if/else statement and I'm stumped. Here's what I want the code to do: If what's in my row starts with "http://" then use a certain code. Else, use a another code. Kind of like this: <? if (CODE TO USE IF THIS ROW CONTAINS "HTTP://") then display this: <img src="<?php echo "{$row[picfile]}"; ?>"> else: <?php if (@mysql_num_rows($pres)) { $i = 0; ?> <table class="adpics" width="100%"><tr><td> <?php while ($row = mysql_fetch_array($pres)) { $i++; $imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height); ?> <img src="<?php echo "{$datadir[adpics]}/{$row[picfile]}"; ?>"> <?php } ?> </td></tr></table> <?php $imgcnt = $i; } ?> Code (markup): As you can see, the only difference really is this code here: <img src="<?php echo "{$datadir[adpics]}/{$row[picfile]}"; ?>"> Any help would be appreciated. Thank you.
Which will storage content for "If what's in my row starts with "http://" then use a certain code. " ? If this is variable , using : $string; if($string == "http://") { // do } else { //do }
Thanks for the reply anhbloginc, much appreciated. The storage is actually being called from {$row[picfile]} In the picfile column in mysql it can contain either a whole url to a picture or the picture name. So, in the if, I need to say if {$row[picfile]} starts with http:// then display my code. Else, display another piece of code. I hope I explained it right. Thanks again.
don't use preg_match that's a waste... <?php if(substr($row['picfile'], 0, 7) == 'http://') { #yep do something here } else{ #nope do something else } ?> PHP: