I enter the number of ids I want to create and submit returns a html table that contains the php uniqid() function ids. (Default is 50,stops at 500)
Then I copy & paste into the spreadsheet that contains the data that will be imported into mysql.
Is this the correct way to import data or is there alternative ways?
Thanks!
Code: Select all
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<h2>Generate nuBuilder ids that can be used when importing data</h2>
<p><span class="error">* required field.</span></p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
How many ids? <input type="text" name="genCnt"><br>
<span class="error">* <?php echo $genCntErr;?></span>
<br><br>
<input type="submit">
</form>
<table border="1"><tbody>
<?php
$genCntErr="";
$genCnt="";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST["genCnt"]))
{
$genCntErr="Defaulted 50 ids";
generateIds(50);
}
else
{
$genCnt = test_input($_POST["genCnt"]);
if(is_numeric($genCnt))
{
generateIds($genCnt);
}
else
{$genCntErr="Enter a valid Number";}
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function generateIds($howMany)
{
for($i=1; $i <=$howMany; $i++) {
if ($i > 500) {
break;
}
echo '<tr><td>',$i,'</td><td>',uniqid(),'</td></tr>';
}
}
?>
</tbody></table>
<span class="error">* <?php echo $genCntErr;?></span>
<br><br>
</body>
</html>