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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.