jquery - 2 values from 1 input, PHP MySQL -
i'm building validator script barcode ticketing system. needs check barcode number against database. thing first 7 numbers of barcode customer id , last 4 numbers seat id.
for example:
12345671234 ^^^^^^^--customer id ^^^^-- seat id
as i'll scan barcode using barcode scanner , write whole barcode on single input box need seperate these 2 values in 1 input in order proper data database.
its like:
<form action="validator.php" method="post"> customer id: <input id="uuid" name="uuid" maxlength="7"><br> seat: <input id="hash" name="hash" maxlength="4">
needs like:
barcode: <input id="barcode" name="barcode" maxlength="11"><input type="submit"> <input type="submit"> </form>
and php side
<?php $uuid = $_post['uuid']; $hash = $_post['hash']; $con=mysqli_connect("localhost","admin","321","db_name"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * seat_booking_bookings uuid ='$uuid'"); while($row = mysqli_fetch_array($result)) { echo $row['customer_name'] . " " . $row['customer_phone']; echo "<br>"; } $result = mysqli_query($con,"select * seat_booking_bookings_seats hash ='$hash'"); while($row = mysqli_fetch_array($result)) { echo "seat:"; echo $row['seat_id'] . " " . $row['price']; } ?>
thanks help.
you can try this,
$uuid = substr($_post['barcode'], 0,7); $hash = substr($_post['barcode'], 7,4);
refer this. php substring
Comments
Post a Comment