PDA

View Full Version : How would i do this ?



Hayd93
09-03-2008, 02:47 PM
Ok i suck at php and all that but how would i do this.

What i want to do is pull a random link out of a database and show it on a page.

ok first how would i put the enterys on the database.2nd what would be the code to show it and 3rd how would i display it on the page would i need a iframe ect ?

+ rep for help
Thanks
Dan

Hypertext
09-03-2008, 06:38 PM
To insert,

<?php
// db connect info including database select
mysql_query("insert into links(linkname, link) VALUES ('somelinkname', 'http://example.com/somelink.php')" or die(mysql_error());
?>

to select..


<?php

//conector info etc

and to select and view
$result = mysql_query("SELECT * FROM links") or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<a href='";
echo "$row[link]";
echo "'>";
echo $row['linkname'];
echo "<a/>
?>

Want to hide these adverts? Register an account for free!