SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help the multiplication

    1. / Your code after this line:

    ".$row["giathue"]."

    2. / Now I want to do multiplication with a variable in the config.php file, that variable is a number.

    <?php
    $itemshow = 3;
    $page = ($pages-1)*$itemshow;
    $stt = $page;
    $orderby = " ORDER BY ".(isset($_GET["sort"])?"giathue ".($_GET["sort"]=="asc"?"ASC":"DESC"):"lastupdate DESC");
    $tsort = isset($_GET["sort"])?"&sort=".$_GET["sort"]:"";
    $SQLString = "SELECT * FROM tin1p WHERE duyet=1 ".(isset($_GET["quan"])?"AND quan='".$_GET["quan"]."'":"");
    $result = mysql_query($SQLString);
    $num_rows = mysql_num_rows($result);
    if ($num_rows){
    $SQLString = "SELECT * FROM tin1p WHERE duyet=1 ".(isset($_GET["quan"])?"AND quan='".$_GET["quan"]."'":"").$orderby." limit $page, $itemshow";
    $result = mysql_query($SQLString);
    while ($row = mysql_fetch_array($result))
    {
    $hinhanh = ret_value("hinhanh","WHERE thutu=1 AND parent=".$row["parent"]." AND phienlamviec=".$row["phienlamviec"],"duongdan");
    if (!isset($_SESSION[$chitiet]))
    {
    echo isset($_SESSION[$chitiet])?"":"";
    $_SESSION[$chitiet] = $baygio;
    $solanxem = $row["solanxem"]+1;
    ret_edit_value("","tin1p","id=".$chitiet,"solanxem ",$solanxem);
    }
    echo "<td width=\"30%\" valign=\"top\" style=\"font-size:12px\">
    <a href=\"\" class=\"small-hotnews-image-\">
    <img style=\"width: 70px;height: 70px;border:3px solid #caccc9;float:left;margin-right:5px\" class=\"sh-news-\" src=\"http://dangkyoffice.com/..".(strlen($hinhanh)?$hinhanh:"/hide.gif")."\" />
    </a>
    <a href=\"http://vanphong.cenrea.com/van-phong-cho-thue-".$row["id"]."-".ret_bo_dau_vn($row["tentoanha"],"-")."-duong-".ret_bo_dau_vn($row["diachi"],"-")."-".$row["quan"].".html\" class=\"hotnews-title-\" style=\"margin-top:5px\" target=\"_Blank\">".$row["tentoanha"]."</a>
    <br />".$quan_array[$row["quan"]]."
    <br />".$row["giathue"]." USD/m2
    </td>";
    }
    }
    ?>
    I want to transfer currency is the dollar amount to Vietnam

    Thank you very much!

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,413
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I would set a variable at the top of the code e.g. $excahange_rate = '1.2'; for the conversion rate so it is easy to find and change then try changing:
    PHP Code:
    <br />".$row["giathue"]." USD/m2
    to
    <br />".( $row["giathue"] * $excahange_rate )." USD/m2 
    Assuming that is the row with the currency in.

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,267
    Mentioned
    116 Post(s)
    Tagged
    1 Thread(s)
    What rubble said was correct, but I would like to make a couple additional comments:
    1. You don't need to assign the variable in quotes - in fact, it's more efficient not to as the server won't have to convert the value before it can do the math.
    2. Please, please, PLEASE do not handle your querystrings like that - you are setting yourself up for SQL injection and problems down the line. I would suggest reading these three threads to solidify your coding style
      1. PHP Basics
      2. Common PHP problems
      3. PHP and mySQL coding tips
    3. There is quite a bit of inline styling going on in there - that's going to end up causing you some problems later on down the road, so I would suggest brushing up on css.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  4. #4
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much. I will try


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •