modigy Posted December 11, 2006 Share Posted December 11, 2006 Hey all,I have some php code that returns search results from the database. It works well except some of the 'commentary' in the DB are very short so the result is the the css style (which is dynamic) results in akward looking results. [code]<?php echo '<p>'; echo '<img src="../images_books/'.$image.'" width="94" height="138" align="left">'; echo '<font color="#7b8049" face="Geneva, Arial, Helvetica, sans-serif"><b>'; echo $btitle; echo '</b></font><br> <b><font color="#000000" size="1" face="Geneva, Arial, Helvetica, sans-serif"> by '.$bauthor.' </font></b> </p> <p><font color="#000000" size="1" face="Geneva, Arial, Helvetica, sans-serif">'.$commentary.'</font></p> <p> <a href="../php/moreinfo.php?id='.$id.'">More Info</a> <a href="../php/addtocart.php?id='.$id.'">Add to Cart</a> </p> <br><hr>';?>[/code]Is there a way to inject some 'spaces' to maintain the formatting of the results yet keep the results page dynamic?Perhaps this is a css question???Thanks in advance,M Link to comment https://forums.phpfreaks.com/topic/30267-mysqlphp-database-results-formatting/ Share on other sites More sharing options...
craygo Posted December 11, 2006 Share Posted December 11, 2006 You can always check the length and then go from there[code]if(strlen($commentary) < 1){ $comm = " "; } else { $comm = $commentary; }[/code]You can use anything you want but just set the desired length you want and what you want to show if it does not pass your check.Then use $comm as your output instead of $commentary[code]<p><font color="#000000" size="1" face="Geneva, Arial, Helvetica, sans-serif">'.$comm.'</font></p>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/30267-mysqlphp-database-results-formatting/#findComment-139229 Share on other sites More sharing options...
modigy Posted December 12, 2006 Author Share Posted December 12, 2006 Craygo,Thanks 'Big, Big' for your help!! That was exactly what I needed!!Cheers,M Link to comment https://forums.phpfreaks.com/topic/30267-mysqlphp-database-results-formatting/#findComment-139635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.