Jump to content

MySQL/PHP database results formatting


modigy

Recommended Posts

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>
&nbsp;&nbsp;
<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

You can always check the length and then go from there
[code]if(strlen($commentary) < 1){
  $comm = "&nbsp;&nbsp;";
  } 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.