nade93 Posted September 15, 2010 Share Posted September 15, 2010 Hi All I am wanting to start writing neater coding so am wanting to refer to coding in a functions file. So for example, If i was getting info from database using the following code $queryone = "SELECT * from affiliate where size='300x250' ORDER BY RAND() LIMIT 1"; $result = mysql_query($queryone); while ($row = mysql_fetch_assoc($result)) { echo "".$row['code'].""; } I would want this to go in a file called functions.php Then in my index.php(for example) I would want to link up to this code. Can anyone point me in the right direction please? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213482-php-functions-and-call-back-help/ Share on other sites More sharing options...
trq Posted September 15, 2010 Share Posted September 15, 2010 http://php.net/functions Quote Link to comment https://forums.phpfreaks.com/topic/213482-php-functions-and-call-back-help/#findComment-1111322 Share on other sites More sharing options...
nade93 Posted September 15, 2010 Author Share Posted September 15, 2010 hi i wrapped a function around coding function affiliateone(){ } and then in index.php linked using <? affiliateone(); ?> and worked a treat! (oh for others using this, you need to include the functions file with <? include('functions.php'); ?> at the beginning of your index file cheers!!!! Quote Link to comment https://forums.phpfreaks.com/topic/213482-php-functions-and-call-back-help/#findComment-1111324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.