$mysqli = new mysqli($server, $username, $password, $username);
$stmt = $mysqli->prepare("INSERT INTO main(tag, val) VALUES (?, ?)");
$tag = $mysqli->query("SELECT tag FROM main");
$val = $mysqli->query("SELECT tag FROM main");
$val = $val + 1;
$stmt->bind_param("si", $tag, $val);
$stmt->execute();
$stmt = $mysqli->prepare("INSERT INTO main(tag, val) VALUES (?, ?)");
$tag = $mysqli->query("SELECT tag FROM main");
$val = $mysqli->query("SELECT tag FROM main");
$val = $val + 1;
$stmt->bind_param("si", $tag, $val);
$stmt->execute();