I have Stream, Academic year, batch and semester as input to fetch students data through php who belongs to these Stream, Academic year, batch and semester passed from html form.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
It would work quite similarly to when receiving a single input instance.
For example let’s say that you wanted to select a user where the user’s last name and first name are specified in your input:
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$sql = 'SELECT lastname,
firstname,
FROM users
WHERE lastname LIKE :lastname OR
firstname LIKE :firstname;';
$q = $pdo->prepare($sql);
$q->execute([':lastname' => $POST['lastname'],
':firstname' => $POST['firstname']]);
$q->setFetchMode(PDO::FETCH_ASSOC);
// print out the result set
while ($r = $q->fetch()) {
echo sprintf('%s <br/>', $r['lastname']);
}
} catch (PDOException $e) {
die("Could not connect to the database $dbname :" . $e->getMessage());
}
I would also recommend this tutorial here on how to use PDO PHP to perform MySQL transactions:
Also, I could strongly recommend learning Laravel as your first PHP framework, as it makes it easy to interact with your database:
Hope that this helps. Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.