NamePros.Com (http://www.namepros.com/)
-   Programming (http://www.namepros.com/programming/)
-   -   SQL Affiliates (http://www.namepros.com/programming/469198-sql-affiliates.html)

Danaldinho 05-14-2008 05:57 AM

SQL Affiliates
 
I have created a couple of fansites now on my favourite music artists and I do the menu on the left hand side of the page. You can see the menu on one of them here: http://www.chamillionairechat.com

Anyway I am getting more and more people who want to affiliate with me and it takes me a long, long time to add their link into the box as there is hundreds of pages like all the lyrics page.

Anyway I was just wondering is it possible for me to do this a quicker way by using SQL

I haven't really used it before except for some phpbb mods

Thanks, Daniel Mousdell :)

-Nick- 05-14-2008 06:38 AM

You can also use PHP Include function and include one other php file with ads code in all the rest of the pages.

Danaldinho 05-14-2008 06:47 AM

Originally Posted by -Nick-
You can also use PHP Include function and include one other php file with ads code in all the rest of the pages.



Like an iframe?

-Nick- 05-14-2008 06:51 AM

Nope it is not Iframe it is pure single page HTML output without an Iframe.

Search for PHP Include Function in google.

You will know exactly what to do :)

Thanks.

netzilla 05-14-2008 07:15 AM

Use this on your (php) page where you want to include the links:

Code:
<?php include("filename.php"); ?>



Here is a basic php script to connect to a mysql database, query, and display the links which would you put into filename.php:

Code:
<?php # db vars $dbuser = "dbuser"; # username $dbpass = "dbpass"; # password $database = "dbname"; # name of database $dbhost = "localhost"; # usually localhost # db connect $dbh = mysql_connect($dbhost, $dbuser, $dbpass) || die ("Unable to connect to host"); $selected = mysql_select_db($database) || die ("Unable to select database"); # query $query="SELECT url from [[tablename]]"; $result=mysql_query($query); $numrows = mysql_numrows($result); $i = 0; while ($i < $numrows) { $url=mysql_result($result,$i,"url"); echo "<a href=\"$url\">$url</a><br>"; $i++; } ?>


Replace:

[[tablename]] = the table name that contains the url data

Danaldinho 05-14-2008 09:03 AM

I have added my menu code into a file called: http://www.lilwaynehq.com/mainmenu.php and on my index.html file i have included: this code instead of the menu code i was using:

Code:
<?php include("mainmenu.php"); ?>


But now on my website: http://www.lilwaynehq.com/ it doesn't show anything :(

Anyone know what is wrong

I will also following this tutorial: http://www.w3schools.com/PHP/php_includes.asp

Thanks

netzilla 05-14-2008 09:38 AM

In order for the php code to be interpreted properly in most cases it must have a .php file extension. If you used the include() code above on your index.html...it will not work.

Danaldinho 05-14-2008 10:47 AM

Thanks mate, that worked brilliantly

Thanks again for your help :D

netzilla 05-14-2008 10:51 AM

Not a problem. Glad to be a help! :)


All times are GMT -7. The time now is 08:33 PM.
Site Sponsors
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0