在我的PHP内部的HTML代码中,我试图创建一个表,我已经创建了它。但是我在每个表数据之间得到了空间。这是代码
<?php
if(isset($_POST['submit']))
{
$num=$_POST['input1'];
$n=$_POST['input2'];
echo "<table border=1 >" ;
for($i=1;$i<=$n;$i++)
{
$ans=$num*$i;
echo "<tr>";
echo "<td> $num <td>";
echo "<td> * <td>";
echo "<td> $i <td>";
echo "<td> = <td>";
echo "<td> $ans <td>";
echo "<br>";
echo "</tr>";
}
}
echo "</table>";
?>
我想删除2个值之间的小空框。请帮我解决一下这个。 提前致谢。
答案 0 :(得分:3)
关闭<td>
个</td>
个for($i=1;$i<=$n;$i++)
{
$ans=$num*$i;
echo "<tr>";
echo "<td> $num </td>";
echo "<td> * </td>";
echo "<td> $i </td>";
echo "<td> = </td>";
echo "<td> $ans </td>";
echo "</tr>";
}
echo "</table>";
}
代码,然后像这样更改代码:
<br>
那里不应该有isset..
,using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Drawing;
using System.Collections;
namespace HuffmanTest
{
class Program
{
public static string ImageToBase64(Image image,
System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
public static Image Base64ToImage(string base64String)
{
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0,
imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
}
static void Main(string[] args)
{
Console.WriteLine("Welcome, The Operation Has Begun.");
var img = new System.Drawing.Bitmap(@"E:\gray.bmp");
string input = ImageToBase64(img, System.Drawing.Imaging.ImageFormat.Bmp);
HuffmanTree huffmanTree = new HuffmanTree();
// Build the Huffman tree
huffmanTree.Build(input);
// Encode
BitArray encoded = huffmanTree.Encode(input);
Console.WriteLine("Encoded: ");
foreach (bool bit in encoded)
{
Console.Write((bit ? 1 : 0) + "");
}
Console.Beep();
Console.WriteLine();
// Decode
string decoded = huffmanTree.Decode(encoded);
Console.WriteLine("Decoded: ");
Console.WriteLine(decoded);
Console.Beep();
Image fout = Base64ToImage(decoded);
fout.Save("E:\\myImage.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Console.WriteLine("Image Saved Sucuessfully.");
char[] s = input.ToCharArray();
int cratio = encoded.Length / s.Length;
Console.WriteLine("Compression Ratio is {0}%", cratio);
Console.ReadLine();
}
}
}
的括号应该在表格关闭元素之外
答案 1 :(得分:0)
使用<td>
时,您需要确保关闭代码<td>Code Here</td>
for($i=1;$i<=$n;$i++) {
$ans=$num*$i;
echo "<tr>";
echo "<td> $num </td>";
echo "<td> * </td>";
echo "<td> $i </td>";
echo "<td> = </td>";
echo "<td> $ans </td>";
echo "</tr>";
}
echo "</table>";
}