如何使用数据库中的数据填充表单中的某些字段?

时间:2014-12-12 16:43:47

标签: javascript php jquery html mysql

我的问题更新

所以对我来说问题是: 怎么做,当我双击表格中的所需行时,该行的name1和name2转移到我的表单的textareas? 有什么建议吗?

HTML:

<form class="form-horizontal" name="credit" action="handler.php" method="post" >onsubmit="return validate_form ( );">
<textarea name="Bank"></textarea> 
<textarea name="BIC"></textarea> 
<button type="button" onclick="NewWindow()">Banks</button>
</form>

使用Javascript:

function NewWindow() 
{
window.open("pagination.php", "_blank", "toolbar=no, scrollbars=no, resizable=no, top=100, left=100, width=600, height=600");
}

pagination.php:

<table>
<tr><td><b>something</b></td><td><b>something</b></td></tr>
 <tr>
<td>Name1</td>
<td>Name2</td>
</tr>
</table>

1 个答案:

答案 0 :(得分:1)

`mysqli_fetch_row()` returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in result set.

示例#1面向对象的样式

<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";

if ($result = $mysqli->query($query)) {

    /* fetch object array */
    while ($row = $result->fetch_row()) {
        printf ("%s (%s)\n", $row[0], $row[1]);
    }

    /* free result set */
    $result->close();
}

/* close connection */
$mysqli->close();
?>

来源:PHP.net is your friend!