xenomorf 1 Report post Posted September 16, 2010 salam semua.. ada sesiapa yang tahu mcm mana nk auto-generate nombor bermula dari 0.0 sampai 7.0. sy nk nombor yg di generate tu ada titik perpuluhan. cthnya >> 0.00, 0.50, 1.00, 1.50, .... selang 0.5 setiap nombor. setakat ni, sy dpt generate nombor bulat (0, 1, 2, 3...) sj. x dpt plak generate nombor yang ada titik perpuluhan. Quote Share this post Link to post Share on other sites
TOYSЯUS 62 Report post Posted September 18, 2010 [quote name='xenomorf' date='16 September 2010 - 10:05 PM' timestamp='1284645950' post='1047930'] salam semua.. ada sesiapa yang tahu mcm mana nk auto-generate nombor bermula dari 0.0 sampai 7.0. sy nk nombor yg di generate tu ada titik perpuluhan. cthnya >> 0.00, 0.50, 1.00, 1.50, .... selang 0.5 setiap nombor. setakat ni, sy dpt generate nombor bulat (0, 1, 2, 3...) sj. x dpt plak generate nombor yang ada titik perpuluhan. [/quote] Salam.. mcm ni kot: [code] for ($i=0;$i<=7;$i=$i+0.5) { printf("%0.2f",$i); echo "<br>"; } [/code] Quote Share this post Link to post Share on other sites
xenomorf 1 Report post Posted September 18, 2010 trima kasih utk kod tu. da dpt bt. okay,, cuba tgok kod ni >> [code]<html> <head> </head> <body bgcolor="#ffffff" text="#808080"> <?php // will create a table for us echo ' <table border=1> <tr> <th>Penetration</th> <th>Force (Div) </th> <th>Force (kN) </th> </tr>'; // creating the table data a.k.a <td> for ($y=0;$y<=7;$y=$y+0.5) { $ys = $y+1; // use for the ID later (Force, Div) $yai = $y+2; // use for the ID later (Force, kN) echo ' <tr> <td>'.printf("%0.2f",$y).'</td> <td><input type="text" size="25px" id="'.$ys.'" /></td> <td><input type="text" size="25px" id="'.$yai.'"/></td> </tr> '; } echo '</table>'; ?> </body> </html>[/code] tiada masalah kn? tp bila sy run kod tu, nilai printf x masuk dlm tag <td>...</td>. Quote Share this post Link to post Share on other sites
TOYSЯUS 62 Report post Posted September 18, 2010 sama2.. oh, kalau gitu cuba gantikan [b]printf[/b] kepada [b]sprintf[/b] Quote Share this post Link to post Share on other sites
xenomorf 1 Report post Posted September 19, 2010 ouch... GRATZ! da berjaya. Trima kasih byk2 [b]TOYSЯUS!![/b] [b][url="../../user/3216-toys%26%231071%3Bus/"] [/url][/b] Quote Share this post Link to post Share on other sites