Try something like this:
$users = array('Mark', 'John', 'Luke', 'Brogan');
foreach($users as $user) {
mysql_query('INSERT INTO student_login (username) VALUES (\'' . mysql_real_escape_string($user) . '\')');
}
To include passwords...
$users = array(
array('Mark', 'markymark'),
array('John', 'ilovelucy'),
array('Luke', '1234567'),
array('Brogan', '!SJ4vkxaH95Smb^2')
);
foreach($users as $key => $value) {
mysql_query('INSERT INTO student_login (username, password) VALUES (\'' . mysql_real_escape_string($value[0]) . '\', \'' . mysql_real_escape_string($value[1]) . '\')');
}
Not too sure what the deal is with your $userltr variable, but it looks like you might be trying to prefix each username with 'sys'.
foreach($users as $key => $value) {
mysql_query('INSERT INTO student_login (username, password) VALUES (\'' . mysql_real_escape_string('sys' . $value[0]) . '\', \'' . mysql_real_escape_string($value[1]) . '\')');
}
Inserting into the database where the password is identical to the username:
$users = array('Mark', 'John', 'Luke', 'Brogan');
foreach($users as $user) {
mysql_query('INSERT INTO student_login (username, password) VALUES (\'' . mysql_real_escape_string($user) . '\', \'' . mysql_real_escape_string($user) . '\')');
}
Barmar thinks this is what you're trying to do:
<?php
include('connection.php');
for($i = 1; $i <= 100; ++$i) {
$username = mysql_real_escape_string('sys' . $i);
mysql_query('INSERT INTO student_login (username, password) VALUES (\'' . $username . '\', \'' . $username . '\')');
}
values('$usernames','$usernames')")should bevalues('".$usernames[$i-1]."','".$usernames[$i-1]."',)")as you want to insert the specific value, not the entire array.