duanlu1950 2014-10-09 11:18
浏览 49
已采纳

如何设置价格行是否会很快显示更新

how to set if price row is comming soon than show update soon

how to set if price row is comming soon than show update soon

mysql

<?


    //connect to database

     mysql_connect('localhost','phone','pasword');
     mysql_select_db('phone');

//////Displaying Data/////////////
$id=$_GET['id']; // Collecting data from query string
if(!is_numeric($id)){ // Checking data it is a number or not
echo "Data Error"; 
exit;
}
$result = mysql_query("SET NAMES utf8"); //the main trick
$q=mysql_query("select * from price where id=$id AND TRIM(model) IS NOT NULL");

//Adds one to the counter
 mysql_query("UPDATE price SET counter = counter + 1 where id=$id ");

 //Retreives the current count
 $count = mysql_fetch_row(mysql_query("SELECT counter FROM price"));
$row=mysql_fetch_object($q);

echo mysql_error();

echo "<table class='hovertable'><tr><td><img src='admin/media/$row->photo' ></td></tr>";
echo "</table>";
?>

example

my rows

2000
3000
comming soon
4900

and this code is showing like this

2000
2000
3000
Warning: number_format() expects parameter 1 to be double, string given in
4900


and i want like this

2000
2000
3000
update soon
4900

how to solve this problem please help me to solve this issue

<?php if($row->price):?><tr class=\"style1\"><td width='200'><b>Price US $:</b></td><td>Price in Dollar: 

    <?php
    function currencyExchange($amount,$baseCurrency,$quoteCurrency) {
    $open = fopen("http://quote.yahoo.com/d/quotes.csv?s=$baseCurrency[0]$quoteCurrency[0]=X&f=sl1d1t1c1ohgv&e=.csv", "r");
    $exchangeRate = fread($open, 2000);
    fclose($open);
    $exchangeRate = str_replace("\"", "", $exchangeRate);
    $exchangeRate = explode(",", $exchangeRate);
    $results = ($exchangeRate[1]*$amount);
    $results = number_format ($results, 2);
    $amount = number_format ($amount);
    $timeStamp = strtotime($exchangeRate[2]);
    $timeStamp = date('F d, Y', $timeStamp);
    $timeStamp = "$timeStamp $exchangeRate[3]";


    echo "$results
";

    }

    // for additional currency ticker symbols visit: http://finance.yahoo.com/currency-converter
    $usd = array('USD','US Dollars');

    $INR = array('INR','Indian Rupees');
    $usd = array('usd','US DOLLARS');

    $b = str_replace( ',', '', $row->price );

    if( is_numeric( $b ) ) {
        $row->price = $b;
    }


    currencyExchange("$b",$INR,$usd); 
    ?></td></tr><?php endif; ?>
  • 写回答

2条回答 默认 最新

  • doutongfu9484 2014-10-09 11:28
    关注

    Test if the amount is numeric before trying to use functions that only work for numbers.

    Replace:

    $results = ($exchangeRate[1]*$amount);
    $results = number_format ($results, 2);
    $amount = number_format ($amount);
    

    with:

    if (is_numeric($amount)) {
        $results = ($exchangeRate[1]*$amount);
        $results = number_format ($results, 2);
    } else {
        $results = 'update soon';
    }
    

    You don't need to call number_format() on $amount because you never print that value.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作