I'm looking for some guidance on how to develop a msql query that loops through elemenets in a php array. The array is constructed from a multiple line list box.
nibbler
0
Newbie Poster
Recommended Answers
Jump to PostDo you want a single query where the values in your array are in the where ? Like this:
$values = implode(",", $your_array); $query = "SELECT * FROM table WHERE column IN ($values)"
Jump to PostCan you tell me what's not working ?
If nothing is displayed, perhaps because you need to
<?php echo $newArray["BNF_Name"]; ?>
I don't know if your site is setup to use <?= as a short tag for echo.
Jump to PostLooks like you need to put single quotes around $value in setting the $query variable, such as follows:
$query = "SELECT * FROM prescribing_test WHERE prescribing_test.Prescriber_Name IN ('$values')";
All 9 Replies
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
nibbler
0
Newbie Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
oldcat
0
Newbie Poster
nibbler
0
Newbie Poster
nibbler
0
Newbie Poster
nibbler
0
Newbie Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
nibbler
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.