I have the following query:

<?php
$query="SELECT * FROM table LIMIT 4";
$result=mysql_query($query);

echo "<tr>";
for($i=1;$i<mysql_num_fields($result);$i++)
{

    echo "<th style='height: 10px; padding: 0px;'>";
    echo mysql_field_name($result, $i);
    echo "</th>";
}

while($row=mysql_fetch_row($result))
{
    echo "<tr>";
    for($j=1;$j<$i;$j++)
    {
    echo "<td style='height: 10px; padding: 0px;'>";
    echo $row[$j];
    echo "</td>";
    }
    echo "</tr>";
}

echo "</tr>";

?>

What I am trying to do is echo a URL from the database. I have added the URL into the database as <a href="http://somesite.com">Some Site</a>. It echoes the URL but cuts it off, for some reason it only gives me the first 7 characters of the displayed link. For example, the echoed URL would be "Some Si". Could someone please tell me what I am doing wrong? I also want to mention that the field contains additional text besides the URL. Thanks.

Member Avatar for diafol

your db field isn't long enough. The field should be 'varchar' datatype, set it to 200 or something, else if you think the whole text will be longer than 256 characters, use the 'text' datatype.

I had a suspicion that was what it was, thanks for the simple fix.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.