Hi, I'm fairly new to php and sql, and was wondering if this question could be easily answered, I'll do my best to be as concise as possible;

I have a table within a database that I'm using to return basic searches for my company to find specific products, i.e a scale that has a capacity of 300kg, if you search 300kg, it will return all scales with a 300kg capacity field, and the rest of the information about that scale too, one field is a link to that scale's page on our website, but it's not defined as a genuine hyperlink, just text that needs to be copied, is there a simple way around this?

Example returned result from a search:

ID: 1
Cost: £235
Weblink: http://www.weighingscales.com/results2.asp?ID=369

Example Code:

<?php

while ($row = mysql_fetch_array($sql)){
echo 'ID: '.$row['ID'];
echo '<br/> Cost: '.$row['Cost'];
echo '<br/> Weblink: '.$row['Weblink'];
echo '<br/>';
    }
?>

Many thanks!

Your problem is not clear. What is the value of the Weblink field and what would you like to display in the browser?

The field is a varchar and the input form simply asks you to write the weblink, I write it has http://website.com and submit the form, which saves the information in my table. I then query the table and it outputs in a simple form, but the link isn't selectable as a link, it's just text, is there a different value I can apply to that field to make it output as a hyperlink in a table? I can show you the page if necessary, many thanks for taking the time to respond.

Your's seems to be an HTML problem, not MySQL. To display a link you have to code it as a <a ...> tag. In your case that might read:

echo '<br/> Weblink: <a href="' . $row['Weblink'] . '">' . $row['Weblink'] . '</a>';

Again, the output displays as text, not a hyperlink, it may be an extremely obvious mistake, the search is entirely based on 'term', if you look here:

http://bencraven.comyr.com/

The two boxes in the left column at the top, both work individually but not together, and they will display the output in the box on the right, many thanks.

Edit: A good example search would be '300kg' in the Capacity field.

This is how your HTML output for one row reads:

<tr>
<td><font face="Arial, Helvetica, sans-serif">East High</font></td>
<td><font face="Arial, Helvetica, sans-serif">B102</font></td>
<td><font face="Arial, Helvetica, sans-serif">150kg</font></td>
<td><font face="Arial, Helvetica, sans-serif">50g</font></td>
<td><font face="Arial, Helvetica, sans-serif">http://www.weighingscales.com/results2.asp?ID=353</font></td>
<td><font face="Arial, Helvetica, sans-serif">Parcel</font></td>
<td><font face="Arial, Helvetica, sans-serif">£84</font></td>
<td><font face="Arial, Helvetica, sans-serif">372x372</font></td>
</tr>

This is how it should read:

<tr>
<td><font face="Arial, Helvetica, sans-serif">East High</font></td>
<td><font face="Arial, Helvetica, sans-serif">B102</font></td>
<td><font face="Arial, Helvetica, sans-serif">150kg</font></td>
<td><font face="Arial, Helvetica, sans-serif">50g</font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href='http://www.weighingscales.com/results2.asp?ID=353'>http://www.weighingscales.com/results2.asp?ID=353</a></font></td>
<td><font face="Arial, Helvetica, sans-serif">Parcel</font></td>
<td><font face="Arial, Helvetica, sans-serif">£84</font></td>
<td><font face="Arial, Helvetica, sans-serif">372x372</font></td>
</tr>

Advice:
1) Learn some more HTML.
2) Learn how to use CSS to format recurrent elements (like your table rows and cells).
3) Do not store anything in your database which is a constant or can be calculcated from the content. In this case the string "http://www.weighingscales.com/results2.asp?ID=" is a constant which belongs in your code rather than your database.
4) Check your spelling ("incriments").
5) Do not store numerical values as strings (your capacity and increment fields). How would you search for a capacity between 50kg and 100kg in your design?

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.