Forum Moderators: coopster

Message Too Old, No Replies

echoing to the table

         

Flolondon

5:25 pm on May 6, 2006 (gmt 0)

10+ Year Member



echo food($cars);

This is the botton bit of the function... how do I echo it to the table..considering i have used another function before with the same variable to the below html table please. I know the answer should not be $cars by itself. Its a botton piece of a function code.

echo " </tr>\n";
echo " <tr>\n";
echo " <td>vehicles</td>\n";
echo " <td bgcolor=\"#CCFF99\"> </td>\n";
echo " </tr>\n";
echo " </tr>\n";
echo " </table>\n";

eelixduppy

9:28 pm on May 6, 2006 (gmt 0)



hello...

Do you mean something like this:


echo food($cars); //food() must have a return value!
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>vehicles</td>\n";
echo " <td bgcolor=\"#CCFF99\"> </td>\n";
echo " </tr>\n";
echo " </tr>\n";
echo " </table>\n";

I hope this answers your question. good luck!

eelix

Flolondon

12:14 pm on May 8, 2006 (gmt 0)

10+ Year Member



thank you but i was wanting it to echo

echo " <td bgcolor=\"#CCFF99\"> here</td>\n";

Sarah Atkinson

12:33 pm on May 8, 2006 (gmt 0)

10+ Year Member



I'm not sure I follow you. What does your function do? And where do you want to echo it to?

Flolondon

12:34 pm on May 8, 2006 (gmt 0)

10+ Year Member



I want to echo the results between the td bits of the html code so that presentation looks fine...

Flolondon

1:29 pm on May 8, 2006 (gmt 0)

10+ Year Member



function vehicle($cars) {

switch ($cars) {
case "white":
$pricestr = " This white car will cost £6.00 plust VAT\n" ;
break;

case "blue":
$pricestr = " Blue our latest speciality will cost £7.00 plus VAT\n" ;
break;

case "grey":
$pricestr = " grey will cost £8.00 plus VAT\n" ;
break;

case "orange":
$pricestr = " orange will cost £7.50 plust VAT.\n" ;
break;
}
return $pricestr;
}

echo vehicle($cars);
?>

i want to echo the results precisely in a specific table space above.

eelixduppy

1:56 pm on May 8, 2006 (gmt 0)



Ok...so something like this:

echo "<td bgcolor='#CCFF99'>".food($cars)."</td>\n";

eelix

Sarah Atkinson

5:13 pm on May 8, 2006 (gmt 0)

10+ Year Member



<td bgcolor='#CCFF99'><?php echo food($cars);?> </td>\n

Although I allways put mine into variables So I would have something like
$cars='white';
$foo=food($cars);
<?php echo $foo;?>

but this is just me and prob. not the best way to go.

Flolondon

3:48 pm on May 9, 2006 (gmt 0)

10+ Year Member



Thank you very much all...it worked..