English 中文(简体)
按项目组合中提交表格对超文本表格的栏和行数进行调整
原标题:Adjust the amount of columns and rows for a HTML table by form submission in PHP

我制作了一个有3行的表格,每行各有5栏,每栏有3个投入箱,如下栏所示。

“entergraph

我谨提交这一表格并提出一个表格。 表格的结构将根据表格数据确定。

例如:

  1. If I submit the form as below:

“entergraph

它将建立一个这样的表格:

“entergraph

(两行,第一行有两栏,第二行有一栏)

我认为,我需要这样写一个巨大的<条码>,如果是的话,这种情形的代号是某人是否有写这一逻辑的想法? 仅作简单/细谈。

欢迎讨论。

问题回答

这只是算法,但是,在php中执行算法应当足够简单。

  1. Loop over the entire post to see how many rows have been returned, and which row has the max columns.
  2. Create a table
  3. In first row, add the number of cells you require, such that the colspan for each cell is maxCols / thisRowCols
  4. do this for all rows

我在此逻辑中看到的唯一告诫是,如果是maxCols / thisRowCols的结果。 不是愤怒的,而是你们要么与自己一起生活,要么思考一下:

http://www.ohchr.org。

如果你赞同该办法,

if(thisRowCols != maxCols) {
    echo("<td colspan="", maxCols / thisRowCols, "">&nbsp;</td>");
} else {
    echo("<td>&nbsp;</td>");
}

如果您有<代码><td>...,则载于html代码。

<td <?php if(thisRowCols != maxCols) { echo("colspan="", maxCols / thisRowCols, """);} ?> >&nbsp;</td>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签