Jump to content

php functions and call back help


nade93

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/213482-php-functions-and-call-back-help/
Share on other sites

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!!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.