|
Posted by Tom Chubb on 07/30/05 23:37
Thanks guys for all your help.
I've managed to get it working.
I tried calling the function from within the file and it turned out
that somehow I had messed up my include statement.
I understood about adding argument variables to the syntax, but I
needed to add a text argument as I couldn't think of a way of setting
the variable in a way that I could distinguish between different
values for different tables on the same page.
Anyway, thanks to you all for taking some time to help me out.
T
On 30/07/05, Rory Browne <rory.browne@gmail.com> wrote:
> You're declaring your function wrong.
>
> You're doing:
>
> function (function_name)
>
> You should be doing
>
> function function_name($arg1, $arg2, $arg3) // with as many comma
> seperated arguments as you want.
>
> or if you don´t want to pass any arguments
>
> function function_name()
>
>
> Try this out:
>
> function make_table($arg1, $arg2){
> ?>
> <table>
> <tr>
> <td><?php echo $arg1; ?></td>
> <td><?php echo $arg2; ?></td>
> </tr>
> </table>
> <?php
> }
>
> note that I have to go back into PHP twice to get the variables.
>
> I could also (although tbh you should wait until you have more
> experience before you read on)
>
> function make_table($arg1, $arg2){
> echo <<<ENDOFTABLE
> <table>
> <tr>
> <td>$arg1</td>
> <td>$arg2</td>
> </tr>
> </table>
> ENDOFTABLE;
> }
>
>
>
>
> On 7/30/05, Tom Chubb <tomchubb@gmail.com> wrote:
> > I am trying to start using functions on some pages to layout a header
> > row in a table.
> > I have defined the function as below...
> >
> > <?php
> > function (headerrow)
> > { ?>
> > <table width="750" border="0" cellpadding="0" cellspacing="0"
> > bgcolor="#FF0066">
> > <tr>
> > <td class="table_head"><?php echo $tablehead; ?></td>
> > <td width="20"><img src="/nav/images/pspromo_table_rhs.gif"
> > width="20" height="20"></td>
> > </tr>
> > </table>
> > <?php
> > }
> > ?>
> >
> >
> > What I can't seem to work out is a way to set the text. Here I've
> > echoed the $tablehead value, but it I was to use more than one table
> > on the same page then it wouldn't work. Can I do something like
> > headerrow(text goes here) or something?
> > I can't understand the use of arguments and it's really confusing me!
> > Any help would be really appreciated.
> > Thanks,
> >
> > Tom
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--
Tom Chubb
tom@ps-promo.co.uk
07915 053312
Navigation:
[Reply to this message]
|