Adding Data information

Adding data to the devices table

You may wish to add a couple more items of data by modifying $query as follows and calling up the program in your browser again:

$query = “INSERT INTO devices VALUES(NULL, ‘Minidisc’, ‘Sony’, 2)”;
$query = “INSERT INTO devices VALUES(NULL, ‘Dat’, ‘Sony’, 3)”;

By the way, notice the NULL value passed as the first parameter? This is because the id column is of type AUTO_INCREMENT, and MySQL will decide what value to assign according to the next available number in sequence. So, we simply pass a NULL value, which will be ignored. Of course, the most efficient way to populate MySQL with data is to create an array and insert the data with a single query.

Leave a Reply

Your email address will not be published. Required fields are marked *