PHP help needed PLEASE

Associate
Joined
18 Jan 2006
Posts
261
Location
Tonyrefail
Hi all,

I simply want a page to display a list of links that are stored in a SQL database. The database has 3 fields ID, URL and Title. I currently have the page displaying a list of the Titles. Example:

PNY GeForce 8800 GTX Review
8800 GTX review - TechSpot
GeForce 8800 GTS & GTX review

Now i want the corresponding URLs to be used as the hyperlinks for the page Titles. I have nearly got this working except each of the Titles are using the first URL as their hyperlink. I created a test page for you to see.

http://students.comp.glam.ac.uk/04033299/blg/display links.php

In dreamweaver ive got the following php code:

<?php do { ?>
<tr>
<td><?php echo $row_DisplayLinks['ID']; ?></td>
<td><?php echo $row_DisplayLinks['URL']; ?></td>
<td><a href="<?php echo $row_Test['URL']; ?>"><?php echo $row_DisplayLinks['Title']; ?></a></td>
</tr>
<?php } while ($row_DisplayLinks = mysql_fetch_assoc($DisplayLinks)); ?>

I think this needs to be changed: <?php echo $row_Test['URL']; ?>

By the way this is for my dissertation so any help will be very appreciated :D
Thanks in advance
 
Last edited:
Im assuming this is what you want:

Pull all data out of the database and make each one a link.

So :

PHP:
				<?php
				
				$result = mysql_query("SELECT * FROM TABLENAME")
				or die(mysql_error());  
				while($row = mysql_fetch_array($result))
				
					{
						echo "<a href=" . $row['URL'] . ">" . $row['Title'] . "</a>";
						echo "</br>";
					}
				?>

Im new to PHP myself but that might work :D better than no replies I suppose :p
 
Back
Top Bottom