[thelist] one more PHP question - using a function

Matt Slocum matt.slocum at gmail.com
Mon Oct 15 12:08:01 CDT 2007

Tom, I'm not sure I understand your question.

This is what I do. When it comes to php flow. I would avoid having long
chunks of code running outside a function. I recommend separating each
segment of a page into its own function.

At the begging of the php use conditional statements to control which
workflow gets done.

Is that even close to your question???


On 10/15/07, Tom Dell'Aringa <pixelmech at gmail.com> wrote:
> Thanks for all the answers folks, really helpful. One more question. I
> want
> to use a function to call the data when the user clicks a link. If I don't
> I
> end up with errors because code is just running willy nilly in the page.
> So I have this example function
> function GetRaceinfo($raceId)
> {
>     // make sure there is a race id selected before attempting to pull
> data
>     if(isset($raceId))
>     {
>     ...do some stuff, etc....
>     }
> }
> Then I have the link that is being written out like so:
> <a href=\'events.php?id=\'' . $info['id'] . '>' . $info['name'] . '</a>
> How can I switch this so when the link is clicked, it still calls
> events.php?id=
> but it does it via the function instead? Would I just do this:
> <a href='<?php GetRaceinfo(' . $raceId .  ')?>'>linkname</a>
> then at the end of my function use header to hit the page?
> header('Location: http://blah.com/events.php?id=4');
> I'm thinking I've got something backwards here though...
> CC me at pixelmech at gee mail dot com if you can...thanks!
> Tom
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !

More information about the thelist mailing list