iT邦幫忙

0

使用PHP寫出加減乘除

如圖,需要完全使用PHP寫出
謝謝!http://ithelp.ithome.com.tw/upload/images/20170630/20106116KJ629DZAgt.png

q00153 iT邦新手 3 級 ‧ 2017-06-30 15:20:15 檢舉
我怎麼感覺這截圖是 office 系列的東西 O.O....
office 系列應該要用 VBA 來做才對,不能用 PHP 喔

如果是要網頁架構這樣的畫面,要學習的是 HTML & css,

如果要有計算功能可以研究一下 javascript & jQuery,

如果是學校老師指定用 PHP 那翻一下上課的教材,
基礎的東西應該都有教的。
小魚 iT邦大師 1 級 ‧ 2017-06-30 19:48:09 檢舉
這個排版看起來的確不像網頁的,網頁比較少會這樣排版...除非是當作作業練習。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
2

自己的國家自己救
自己的作業自己寫
要答案?
沒門!

可樂好兇~/images/emoticon/emoticon37.gif

0
黃彥儒
iT邦高手 1 級 ‧ 2017-06-30 15:20:03
<?php
echo "<img src=\"http://ithelp.ithome.com.tw/upload/images/20170630/20106116KJ629DZAgt.png\">";
//詳細的
?>

超簡單

看更多先前的回應...收起先前的回應...
jeles51 iT邦研究生 3 級 ‧ 2017-06-30 15:30:24 檢舉

good~

你沒有寫詳細的註解……

正解阿~!!!!/images/emoticon/emoticon12.gif

小魚 iT邦大師 1 級 ‧ 2017-06-30 19:46:24 檢舉

太強了
/images/emoticon/emoticon34.gif

黃彥儒 iT邦高手 1 級 ‧ 2017-07-01 02:27:05 檢舉

Samと可樂快跑我加上註解了

小魚 iT邦大師 1 級 ‧ 2017-07-01 12:23:56 檢舉

果然是 "詳細的" 註解
/images/emoticon/emoticon10.gif

0
wolfwang
iT邦研究生 4 級 ‧ 2017-07-03 18:55:48

交流一下,用JS的版本

<!DOCTYPE html>
<html lang="en">
        
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        input {
            font-size: 18px;
            color: #666
        }
        button {
            font-size: 20px;
            width: 25px;
            text-align: center
        }
        #result {
            display: inline-block;
            width: 100px;
            border: 1px dashed #666;
            padding: 5px;
            font-size: 20px;
            text-align: center
        }
    </style>
    <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
</head>

<body>
    <input type="text" id="n1" size="10" value="0" />
    <input type="text" id="n2" size="10" value="0" />

    <button id="plus">+</button>
    <button id="minus">-</button>
    <button id="times">X</button>
    <button id="divid">/</button>

    <span id="result">Result</span>
    <script>
        $(function() {
            var collectNum = function() {
                return [Number($("#n1").val()), Number($("#n2").val())];
            }
            var showNum = function(result) {
                $("#result").html(result);
            }
            $("button").click(function() {
                var nums = collectNum();
              
                switch ($(this).attr("id")) {
                    case "plus":
                        showNum(nums[0] + nums[1]);
                        break;
                    case "minus":
                        showNum(nums[0] - nums[1]);
                        break;
                    case "times":
                        showNum(nums[0] * nums[1]);
                        break;
                    case "divid":
                        showNum(nums[0] / nums[1]);
                        break;
                }
            });
        });
    </script>
</body>

</html>

0
mouscee
iT邦見習生 ‧ 2017-07-07 11:33:59

SUBMIT 也可以傳值的

<?php

	 $num1=$_POST['num1'];
	 $num2=$_POST['num2'];
	 if($_POST['a']=='+')
	 { $total=$num1+$num2;}
	 if($_POST['a']=='-')
	 { $total=$num1-$num2;}
	 if($_POST['a']=='*')
	 { $total=$num1*$num2;}
	 if($_POST['a']=='/')
	 { $total=$num1/$num2;}
 
?>
<form action="test888.php" method="post" name="form">

<table width="30%" border="0">
  <tr>
    <td rowspan="4"><input name="num1" type="text" size="5" value="<?php echo $num1;?>"/> &nbsp;&nbsp;<input name="num2" type="text" size="5" value="<?php echo $num2;?>"/></td>
    <td><input name="a" type="submit" value="+" onclick=""/></td>
    <td rowspan="4"><input name="resullt" type="text" value="<?php if($total=="" && $total!="0"){echo "Result";}else{echo $total;}?>" readonly="readonly" /></td>
  </tr>
  <tr> 
  <td>
    <input name="a" type="submit" value="-" onclick=""/>
  </td>
  </tr>
  <tr>
  <td> 
    <input name="a" type="submit" value="*" onclick=""/>
  </td>
  </tr>
  <tr>
  <td> 
   <input name="a" type="submit" value="/" onclick=""/>
   </td>
  </tr>
</table>
</form>

我要發表回答

立即登入回答