html - Inserting a table into a PHP while statement -


i have created wrote php code includes array , while statement. need put results table shown below. tried many different ways had no luck if can point me in right direction grateful. (new php)

table example

http://main.xfiddle.com/b5a1cb57/test.php

    <!doctype html> <html> <head> <link type="text/css" rel="stylesheet" href="main.css"/> <title>loops</title> </head> <body> <?php echo "<b>associative arrays </b><br />";  $prices = array('t-shirt'=>'9.99','cap'=>'4.99','mug'=>'6.99'); echo "<br />"; print_r($prices);  echo "<h1>loops</h1><br />";  echo "<b>while looop</b><br />"; echo "<br />";   $shirt_price = $prices['t-shirt']; $counter = 1;  while ($counter<=10)  {$price2 = ($counter*$shirt_price);   echo $counter . ' ' . $price2 . '<br />';  $counter++; }  ?>      </body> </html> 

try starting out simple this

echo '<table>'; while ($counter<=10) {     $price2 = ($counter*$shirt_price);     echo "<tr><td>$counter</td><td>$price2</td></tr>";     $counter++; } echo '</table>'; 

once working can @ things can table make better etc.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -