1.11M Members

live links.

 
0
 
<?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.

 
0
 

echo out your $row 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.

 
0
 

You can break out of the php tags to make it a bit more manageable:

<td><a class="mylink" href="<?php 'www.'.$row['website']; ?>"> <?php echo "www.$row['website']" ?></a></td>

You'll also need an image link for the thumbnail...

<td> <img src="/path/of/image" alt="image description" href="<?php $row['url'] ?>" height="78px" width="78px"></td>

This prints "www.outputsite.com" and the link URL will be exactly the same. I think that's the solution to the problem as I understand it anyway

 
0
 

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 ?

 
1
 

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.

 
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.

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 "<td><a class=\"mylink\" 'http://' href=\"http://" . $row . "\">" . $row . "</a></td>";

WORKS

still stuck getting image link to show.

 
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 "<td><a class=\"mylink\" 'http://' href=\"http://" . $row . "\">" . $row . "</a></td>";

WORKS

still stuck getting image link to show.

Have got image to show with ,

echo "<td><img class=\"image\" src=\"http://" . $row . "\" /></td>";

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

 
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.

 
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.

echo "<td><img class=\"image\" ' width="200" ' src=\"http://" . $row . "\" /></td>";

where is this wrong please ?

 
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.

 
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.

this line works , only it gives the image as any size it gets from the url`s ,

echo "<td><img src=\"http://" . $row . "\" /></td>";


this line

echo "<td><img src=\"http://" . $row . "\" /></td>"; width = "75"

dos not, no matter where i place the " width " part,

 
1
 

The width is part of the image tag

echo "<td><img width = '75' src='http://". $row['url'] . "' /></td>";
 
1
 

or even:

echo '<td><img class="img" width = "75" src="http://' . $row['url'] . '" /></td>';
 
0
 

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>
Question Answered as of 3 Years Ago by diafol, nonshatter and pzuurveen
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: