Salve a tutti. avrei la necessità di inserire in un campo della tabella una serie di caratteri alfanumerici consecutivi (aa001-aa200)
uso questo codice ma ovviamente non funziona.
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="stile.css" type="text/css" rel="stylesheet" />
<meta content="it" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<script type="text/javascript" src="/table/jquery.js"></script>
<title>Inserimento</title>
</head>
<body style="width: 672px; height: 289px">
<p class="auto-style1" style="width: 293px; height: 24px">DATI</p>
<form method="post" action="" style="width: 674px; height: 130px">
<label><b> Da :</label></b><input id= "passa" name="passa" type="text" /><br />
<label><b> a:</label></b><input id ="passa1" name="passa1" type="text" onChange="javascript:this.value=this.value.toUpperCase();" /> <br />
<input name="Submit1" type="submit" value="Invia" /><br />
</form>
<?php
error_reporting(1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("track_errors", 1);
ini_set("log_errors", 1);
$con=mysqli_connect("localhost","xxx","xxx","test");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['Submit1'])){
$passa=addslashes($_POST['passa']);
$passa1=addslashes($_POST['passa1']);
$result=mysqli_query($con,"INSERT INTO passat (passa) VALUES ");
$vals = array();
for($i = $passa; $i <= $passa1; $i ++) {
$vals[] = "('$i')";
}
$result .= implode(',', $vals);
$stmt = $con->query($result);
if(!$result){
$message="Problem in Adding to database. Please Retry.";
} else {
header("Location:index.php");
}
} mysqli_close($con);?></body></html>
Come posso fare?