如何将随机值插入SQL Server表? [英] How can I insert random values into a SQL server table?

查看:156
本文介绍了如何将随机值插入SQL Server表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码和tablename:table1

数据库:tesync



i尝试使用php代码生成随机数,我得到了但我怎么能得到





插入到sql数据库中



我尝试了什么:



this is my code and tablename:table1
database:tesync

i tried the php code for generating random numbers and i get that but how can i get


the inserted that into sql database

What I have tried:

<?php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
    die("Database Connection Failed" . mysqli_error($connection));
}
$select_db = mysqli_select_db($connection, 'tesync');
if (!$select_db){
    die("Database Selection Failed" . mysqli_error($connection));
}


for ($i=1;$i<=100;$i++)
{

$randomNumber= rand(1111111111,9999999999);

 echo $randomNumber.'<br>';
}
 ?>

推荐答案

连接 = mysqli_connect(' localhost' ' root'' ');
if (!
connection = mysqli_connect('localhost', 'root', ''); if (!


connection){
die( 数据库连接失败 .mysqli_error(
connection){ die("Database Connection Failed" . mysqli_error(


connection));
}
connection)); }


这篇关于如何将随机值插入SQL Server表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆