Here is my code:
<?php $connection = mysql_connect("myserver.com","myuser","mypassword") or die ("Couldn't connect to server."); $db = mysql_select_db("mydb", $connection) or die ("Couldn't select database."); $search=$_POST['search']; $data = "SELECT firstname, lastname, task FROM inventors WHERE taskdate - curdate() = 1"; $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error()); $data2 = mysql_fetch_array($query); echo "$data2[firstname] "; echo "$data2[lastname] "; echo "$data2[task]"; ?>
In my database, I have two records that meet the criteria.
When I run the select in MySQLAdmin, it brings me two records.
The PHP, though, echoes only one.
What's wrong with the code?