pdo phpを使用してEnterキーを押したとき、次のテキストボックスに移動するにはどうすればよいですか?私は私のPHPのコーディングをチェックするのに役立つ誰かが必要です。私のデータベース名は、testphp_db、私のテーブル名は、ユーザはです。pdo PHPを使用してEnterキーを押したときに次のテキストボックスに移動するにはどうすればよいですか?
testphp_db.php
<?php
$dsn = 'mysql:host=localhost;dbname=testphp_db';
$username = 'root';
$password = '';
try{
//Connect To MySQL Database
$con = new PDO($dsn,$username,$password);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $ex) {
echo 'Not Connected '.$ex->getMessage();
}
$barcode = '';
$detail = '';
$quantity = '';
function getPosts()
{
$posts = array();
$posts[0] = $_POST['barcode'];
$posts[1] = $_POST['detail'];
$posts[2] = $_POST['quantity'];
return $posts;
}
//Search And Display Database
if(isset($_POST['search']))
{
$data=getPosts();
if(empty($data[0]))
{
echo 'Enter Barcode To Search';
} else {
$searchStmt=$con->prepare('SELECT * FROM users WHERE barcode = :barcode');
$searchStmt->execute(array(':barcode'=>$data[0]
));
if($searchStmt)
{
$user=$searchStmt->fetch();
if(empty($user))
{
echo 'No Data For This Barcode';
}
$barcode=$user[0];
$detail=$user[1];
$quantity=$user[2];
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP (MySQL PDO): Search</title>
</head>
<body>
<form action="testphp_db.php" method="POST">
Barcode: <input type="text" name="barcode" value="<?php echo $barcode;?>"><br><br>
<input type="submit" name="search" value="Search"><br><br>
Detail: <?php echo $detail;?><br><br>
Quantity: <input type="text" name="quantity" value="<?php echo $quantity;?>"><br><br>
</form>
</body>
</html>
私が入力した自分のバーコードのテキストボックスとプレスに番号を挿入すると、それは、製品の詳細を表示します。私の問題は、入力用のカーソルが消えてしまい、数量テキストボックスに移動できないことです。
コードを入力する必要がありますが、ソリューションが実際にJavascriptになるように思えます。 – Terminus
私のコードを確認できますか?コードをアップロードするだけです。 –