Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old July 23rd, 2004, 05:24 PM
LLX LLX is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Glendale, CA, USA
Posts: 1,121 LLX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 43 m 44 sec
Reputation Power: 3
Send a message via AIM to LLX Send a message via Yahoo to LLX
A Lesson in Functions

Just a little lesson in fonctions for everyone out there.

Say you have some deta that all the same basic look but sime different data, say a listing of books and you dont want to have to loop a file try this

php Code:
Original - php Code
  1.  
  2. // declare the function to be used
  3. function BookDisply($imageurl, $descrip, $avail, $USPrice, $CANPRICE){
  4. /* now code it as you would normally co de the outpit for one item, rember anything theirs a varible/changeing item puta varibl in its place in the code and cocatonat e it with periods so it flows evenly, and every variable you use in the function below put its varible in the () of the function decleration above.
  5. */
  6. echo '<table width="75%" border="0" align="center" cellpadding="0" cellspacing="3"><tr><td width="35%" align="center">';
  7. echo '<img src="' . $imageurl . '" border="1"></td><td><p><font color="#000000" size="2" face="Arial">' . $descrip . '<br>';
  8. echo '<font color="#FF0000">' . $avail . '</font></font>';
  9. echo '<table width="35%" border="0" cellspacing="0" cellpadding="0">';
  10. echo '<tr><td width="25%"><font color="#FF0000" size="2" face="Arial">Price:</font></td>';
  11. echo '<td width="28%"><font color="#FF0000" size="2" face="Arial">' . $USPrice . '</font></td>';
  12. echo '<td width="47%"><font color="#FF0000" size="2" face="Arial">US</font></td></tr><tr>';
  13. echo '<td><font color="#FF0000" size="2" face="Arial">&nbsp;</font></td>';
  14. echo '<td><font color="#FF0000" size="2" face="Arial">' . $CANPRICE . '</font></td>';
  15. echo '<td><font color="#FF0000" size="2" face="Arial">CAN</font></td>';
  16. echo '</tr></table></td></tr></table><BR>';
  17. }


so what does this do for us?

php Code:
Original - php Code
  1.  
  2. BookDisply("letscountSM.jpg", "Let's Count, with its attractive, vivid illustrations of amusing animals is a fun way to teach young readers to count from 1 to 10.", "Will be available in stores by August 2004", "$15.99", "$24.99");


Every time we call the function and populate its "fields" in the () they replae the variables in the function and produce you little display, now yo dont need 13 tables only 1 and just have to give it the values you want for each table!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > A Lesson in Functions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway