Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
<?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>';
}
 ?>
Posted
Updated 11-Apr-17 22:07pm
v2
Comments
Mohibur Rashid 12-Apr-17 3:03am    
This is mysql
any way try google. you will get your answer
Richard MacCutchan 12-Apr-17 3:28am    
Probably by coding an INSERT statement.
Member 13122800 12-Apr-17 4:07am    
where i hve to insert the sql query
Richard MacCutchan 12-Apr-17 4:13am    
Wherever you need the data added to the database.
Member 13122800 12-Apr-17 8:22am    
give me the code by copying b/w the above code and one more thing is as the generated numbers getting they automatically inserted into wampp phpmyadmin sql db tables

1 solution

Once you have generated the number, you can insert it in a table like you do for any other datum. Here you may find code samples: PHP Insert Data Into MySQL[^].
 
Share this answer
 
Comments
Member 13122800 12-Apr-17 8:24am    
tried pls i need code copy the above and sent me back the final code for me and 1 more thing is as the generated numbers automatically inserted into phpmyadmin sql table

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900