Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Help po mga ka sb sa convertion

lightkira8

Apprentice
Advanced Member
Messages
74
Reaction score
0
Points
26
Eto po yung code ko need pa lagyan ng 2 radio button na ang name is binary to decimal and roman to decimal convertion di ko po sya makuha ee patulong po mga ka sb di ko makuha yung formula.

<html>
<body>
<form action="page2.php" method="post">
Input Number <input type="text" name="input1"><br>
Binary conversion <input type="radio" name="option" value="b" checked>
Octa conversion <input type="radio" name="option" value="o">
Hexa conversion <input type="radio" name="option" value="h">
Roman Conversion <input type="radio" name="option" value="c">

<br>
<input type="submit" name="submit">

</form>
</body>
</html>

<?php
$x=$_POST["input1"];
$p=$_POST["option"];
$b="";

switch($p){
case "b":
while ($x>1){
$r= $x % 2;
$x=$x/2;
$b=$r . $b;
}
break;
case "o":
while ($x>1){
$r= $x % 8;
$x=$x/8;
$b=$r . $b;
}
break;
case "h":
while ($x>1){
$r= $x % 16;
$x=$x/16;
switch ($r){
case 10:
$r="A";
break;
case 11:
$r="B";
break;
case 12:
$r="C";
break;
case 13:
$r="D";
break;
case 14:
$r="E";
break;
case 15:
$r="F";
break;
case 16:
$r=10;
break;
}
$b=$r . $b;
}
break;
case "c":
$x=$_POST["input1"];
$th=0;
$ths="";
$As=0;
$hs="";
$t=0;
$ts="";
$o=0;
$os="";
$r="";
//thousand
if ($x>1000){
$th = substr($x / 1000,0,1);
$x = $x % 1000;
switch ($th){
Case 1:
$ths = "M";
break;
Case 2:
$ths = "MM";
break;
Case 3:
$ths = "MMM";
break;
}
}
//hundred
if ($x > 100) {
$h = substr($x / 100,0,1);
$x = $x % 100;
switch ($h){
Case 1:
$hs = "C";
break;
Case 2:
$hs = "CC";
break;
Case 3:
$hs = "CCC";
Case 4:
$hs = "CD";
break;
Case 5:
$hs = "D";
break;
Case 6:
$hs = "DC";
break;
Case 7:
$hs = "DCC";
break;
Case 8:
$hs = "DCCC";
break;
Case 9:
$hs = "CM";
break;
}
}
//Tens
if ($x > 10) {
$t = substr($x / 10,0,1);
$x = $x % 10;
switch ($t){
Case 1:
$ts = "X";
break;
Case 2:
$ts = "XX";
break;
Case 3:
$ts = "XXX";
break;
Case 4:
$ts = "XL";
break;
Case 5:
$ts = "L";
break;
Case 6:
$ts = "LX";
break;
Case 7:
$ts = "LXX";
break;
Case 8:
$ts = "LXXX";
break;
Case 9:
$ts = "XC";
break;
}
}
//ones
switch ($x){
Case 1:
$os = "I";
break;
Case 2:
$os = "II";
break;
Case 3:
$os = "III";
break;
Case 4:
$os = "IV";
break;
Case 5:
$os = "V";
break;
Case 6:
$os = "VI";
break;
Case 7:
$os = "VII";
break;
Case 8:
$os = "VIII";
break;
Case 9:
$os = "IX";
break;
}
echo $ths.$hs.$ts.$os;
break;

}
echo $b;
?>
 
Last edited:
Kailangan ba talaga php? kasi kung conversion lang pwede naman JavaScript lang.
 
kahit ung mga formula nalang sir nagawa mo ba sa javascript?
 
boss anu formula sa roman to decimal convertion?
 
Back
Top Bottom