live links.
<?php
// open base
$con = mysql_connect("xxxxxxxxxxx", "xxxxxxxxxxx", "xxxxxxxxxxxxxxxxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxxxxxxxxxx", $con);
// open table
$result = mysql_query("SELECT * FROM leader");
// print table & column headders
echo "<table border='1'>
<tr>
<th>id</th>
<th>Club</th>
<th>Website</th>
<th>Club Badge Url</th>
</tr>";
// get data to fill table
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['club'] . "</td>";
// gets website url and makes it clickable
echo "<td><a class=\"mylink\" href=\"" . $row['website'] . "\">" . $row['website'] . "</a></td>";
//gets pic. url and displays in box 78 x 78
echo "<td>" . $row['url'] . "</td>";
echo "</tr>";
}
echo "</table>";
// close base
mysql_close($con);
?>
I am working on the above code and have 2 problems {so far}
1/ the links end up like " mysite.com/www.outputsite.com " insted of "www.outputsite.com "
2/ trying to get the url to become a pic insted of just text.
thanks in advance.
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
echo out your $row['website'] to see if it's garbled.
echo "<td>" . $row['url'] . "</td>";
This will not display an image - you need to include an image tag:
echo "<td><img src=\"" . $row['url'] . "\" /></td>";
BTW - you may consider using alt attributes for images and title attributes for links.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
I have tried all the above and keep getting error codes
the output i have at the moment is at http://am1.netau.net/res.php if thats any help ?
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
OK, few things
1) You must place 'http://' in front of your urls or they will point to a page in your site.
2) your images don't exist. Some are truncated - so increase the size of your db field. These also require the 'http://' in front of them.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
OK, few things
1) You must place 'http://' in front of your urls or they will point to a page in your site.
2) your images don't exist. Some are truncated - so increase the size of your db field. These also require the 'http://' in front of them.
i understand that, not a clue how , do i do it in the mysqul data base or in the code above ?
have been looking in the database to add it, cant see where, have loaded sum full url`s in there az defult pics and they still dont show.
for the link line
echo "" . $row['website'] . "";
WORKS
still stuck getting image link to show.
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
i understand that, not a clue how , do i do it in the mysqul data base or in the code above ?
have been looking in the database to add it, cant see where, have loaded sum full url`s in there az defult pics and they still dont show.
for the link line
echo "" . $row['website'] . "";
WORKS
still stuck getting image link to show.
Have got image to show with ,
echo "
";
not got to resizing yet as if the link allready has "http://" when stored it adds it again. trying to learn how to filter the input or output
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
resizing is easy - just apply one dimension, the other will be constrained (same scale):
width="200"
This will display a 400px X 600px [width X height] as 200px X 300px.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
resizing is easy - just apply one dimension, the other will be constrained (same scale):
width="200"
This will display a 400px X 600px [width X height] as 200px X 300px.
echo "
";
where is this wrong please ?
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
seems ok to me. Maybe the image is protected if you are trying to access an image on a remote site. Unless you're using some css or js for the class="image", you don't really need it.
I suggest you hard code what you expect into a plain html file and see if that works:
//edit
OK now I see, you've placed some ' ... ' single quotes in your code - just delete these. If it still doesn't work, try hard coding html into a plain html file to see if that works:
<img class="image" width="200" src="http://www.site.com/image.jpg" />
Obviously change the src to something that is in your DB.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
seems ok to me. Maybe the image is protected if you are trying to access an image on a remote site. Unless you're using some css or js for the class="image", you don't really need it.
I suggest you hard code what you expect into a plain html file and see if that works:
//edit
OK now I see, you've placed some ' ... ' single quotes in your code - just delete these. If it still doesn't work, try hard coding html into a plain html file to see if that works:
<img class="image" width="200" src="http://www.site.com/image.jpg" />
Obviously change the src to something that is in your DB.
this line works , only it gives the image as any size it gets from the url`s ,
echo "
";
this line
echo "
"; width = "75"
dos not, no matter where i place the " width " part,
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
or even:
echo '<td><img class="img" width = "75" src="http://' . $row['url'] . '" /></td>';
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
CHANGE X to your own settings . thanks everyone
<?php
// add data base conections
$con = mysql_connect("xxxxxxxxxx", "xxxxxxxxxxx", "xxxxxxxxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxxxxxxxxxxx", $con);
$result = mysql_query("SELECT * FROM leader");
echo "<table border='9'>
<tr>
// table headders
<th>xxx1xxxxx</th>
<th>xxx2xxxx</th>
<th>xxx3xxxx</th>
<th>xxx4xxxx Url</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['X1'] . "</td>";
echo "<td>" . $row['X2'] . "</td>";
// clickable link
echo "<td><a class=\"mylink\" 'http://' href=\"http://" . $row['X3'] . "\">" . $row['X3'] . "</a></td>";
// image from a url at width size
echo "<td><img width = '75' src='http://". $row['x4'] . "' /></td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
<html>
<body>
<a href="res.php">Link text</a>
Click on <a href="www.link.here">this link</a> to run your first PHP script.
</body>
</html>
Kniggles
Junior Poster in Training
57 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0