[Solved] how can I run mysql script in php?


If you are using the GET method, us $_GET to get the submit form data.

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
session_start();
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 


if(isset($_GET["action"])&&($_GET["action"]=="versave")){ 
$gp_name = $_GET['gp_name'];
$version = $_GET['version'];
$query_vers = "CREATE TEMPORARY TABLE IF NOT EXISTS tmp SELECT * from `gp_info` WHERE `gp_name`= '$gp_name';
UPDATE tmp SET `version` = '$version';
ALTER TABLE tmp DROP id;
INSERT INTO `gp_info` SELECT 0, tmp.* FROM tmp";

if(mysqli_multi_query($conn, $query_vers)){
    echo "query exicute";
}
 //header("Location: gp_data.php");
}
?>

<form id="verForm" name="versaveForm" method="get">
    <input type="hidden" name="action" value="versave">
    <div>
    <input type="text" id="gp_name" name="gp_name">
    <input type="text" id="version" name="version">
    </div>
    <input type="submit" name="vers" value="Version" id="versave">
</form>

4

solved how can I run mysql script in php?