PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Ok, I have a bio page that finds variables stored in a mysql db. One of the fields is called 'links' and has multiple things posted into it using paragraphs to separate each one. I want the displayed links to be separated by a paragraph (or a break). Here is my code:
<?
mysql_connect("localhost","$username","$password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("$database") or die ("Unable to select requested database.");
$query="SELECT links FROM teachers WHERE id='$idcheck'";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$linksshow=mysql_result($result,$i,"links");
echo "
<tr>
<td width='100%'>
<p align='center'><a href='$linksshow'>$linksshow</a></p></td>
</tr>
";
$i++;
}
?>
I tried displaying them a different way, but instead of being separated by a paragraph it is separated by a single space. Should I change the way the links are stored in the DB field or can I fix the code to make it work.
You can't use a <p> tag within a <t> tag -- the browser will ignore it.
If you want more space use multiple spaces, which you must do the hard way,
by using the ampersand and nbsp multiple times.
For separate libes use <br> as Thomas suggested.
And I agree with him, the problem isn't in your bd.
Last edited by Bill H on Thu Dec 02, 2004 9:10 am, edited 1 time in total.
My table tags lie outside the above PHP. I took out the <p> tags and fixed what you told me to fix, but it still doesn't work. I think it may be because of how the links are stored in the DB. The person entering them just types one link, then presses "Enter", types the next link, presses "Enter", etc... and then that info is stored into the DB. If I use the code I have written, will it display it the way I want it to?