logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 09-15-2007, 08:11 PM   #1
owner
 
Join Date: Sep 2007
Posts: 64
Default Help Convert to a function

Hello

I am trying to learn functions and if someone could convert this to a function I could learn off of this, then I could learn how to convert my other code to functions.

PHP Code:
<?php
      
do {
    print 
'<div class="boxtop"><h4 style="margin: 0px; font-size: 10px;">';
    echo 
$row['news_title'];
    print 
'</h4></div>';
    print 
'<div class="boxbottom"><br /><b>';
    echo 
$lang_id$row['news_id'].'<br />';
    echo 
$lang_author$row['news_author'].'<br />';
    echo 
$lang_date$row['news_date'].'</b><br /><br />';
    echo 
$row['news_body'].'</div>';
    } while (
$row mysql_fetch_array($result));
  
?>
That is what I have displaying my news. I don't know anything about functions yet, so if you do choose to help, could you please comment the code so I can learn and see what you are doing.

Thank you soooooo much!
-Owner
owner is offline   Reply With Quote
Old 09-15-2007, 08:38 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

this doesnt lend its self to a function really. You could do it but will be more complicated when debugging

stick it in an include and bobs your uncle

also you have mixed print and echos....?

its better to do it like this..

PHP Code:
<?php do { ?>
    <div class="boxtop"><h4>;
    <?php echo $row['news_title']; ?>
    </h4></div>;
    <div class="boxbottom"><br />;
    <?php echo $lang_id ","$row['news_id']; ?><br />;
    <?php echo $lang_author ","$row['news_author']; ?><br />;
    <?php echo $lang_date","$row['news_date']; ?><br />;
    <?php echo $row['news_body'?></div>;
 
   <?php } while ($row mysql_fetch_array($result)); ?>
also remember to style your code using CSS
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:52 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com