php - Display table data if -
im not sure if you'll i'm asking, i'll try specific , clear possible. have php code :
$result = mysql_query("select * batai svarbumas=1 order id"); while ($row = mysql_fetch_array($result)) { extract($row); $link=$row["linkas"]; echo "<div class='col-md-4'>"; list($width, $height) = getimagesize($link); if($width > $height) { echo "<img src="$link" style='height:234px;margin-left:-33%'>"; } else if($width < $height) { echo "<img src="$link" style='width:234px;margin-top:-33%>"; } echo "</div>"; }
what want do, center given image database div, example, if given images width bigger height, echos left margin. problem is, page displays 2 of elements. one, height bigger width , one, width bigger height.
if don't type ifs , echo image, every image database gets display. hope understand question , thankful advice :)
you need escape double quotes, or use single quotes , concatenate.
if($width > $height) { echo "<img src=\"$link\" style='height:234px;margin-left:-33%'>"; } else if($width < $height) { echo "<img src=\"$link\" style='width:234px;margin-top:-33%'>"; }
or
if($width > $height) { echo '<img src="' . $link . '" style="height:234px;margin-left:-33%">'; } else if($width < $height) { echo '<img src="' . $link . '" style="width:234px;margin-top:-33%">'; }
error reporting have given message such as
parse error: parse error, expecting
','' or
';'' in
so in future should turn on error reporting, http://php.net/manual/en/function.error-reporting.php.
Comments
Post a Comment