开发者

How can I print to table?

I would appreciate it if anyone willing to tell how to echoing /print.

Below is the process of entering data into the database, before inserting it how can I echoing it to the table?

<?php
session_start();
if(isset($_POST['submit']))
{
 include('class/stock_class.php');
 $st = new st_exchange_conv(DEFAULT_SOURCE);
 $from = mysql_real_escape_string(stripslashes($_POST['from']));
 $value = floatval($_POST['amount']);
 $date 开发者_JAVA百科= date('Y-m-d H:i:s');
 $_SESSION['selected'] = $from;
 $stocks = $st->stocks();
 asort($stocks);
 foreach($stocks as $key=>$stock)
 {
  $st->convert($from,$key,$date);
  $stc_price = $st->price($value);
  $stock = mysql_real_escape_string(stripslashes($stock));
  $count = "SELECT * FROM oc_stock WHERE stock = '$key'";
  $result = mysql_query($count) or die(mysql_error());
  $sql = '';
  if(mysql_num_rows($result) == 1)
  {
   $sql = "UPDATE oc_stock SET stock_title = '$stock', stc_val = '$stc_price', date_updated = '$date' WHERE stock = '$key'";
  }
  else
  {  
  $sql = "INSERT INTO oc_stock(stock_id,stock_title,stock,decimal_place,stc_val,date_updated) VALUES ('','$stock','$key','2',$stc_price,'$date')";
  } 
  $result = mysql_query($sql) or die(mysql_error().'<br />'.$sql);
 }
 header("Location: index.php");
 exit();
}
?>


Insert this:

echo "<table><tr><th>".implode(array_keys($stocks), '</th><th>')."</th></tr>";
foreach($stocks as $row) echo "<tr><td>".implode('</td><td>', $row)."</tr>";
echo "</table>";

Edit: If printing the data is the goal and the table-view is not important, I recommend print_r($stocks) instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜