<?php
select1($conn);
function select2 ($conn,$id ,$name)
{
$stmt = $conn->prepare("SELECT def FROM define WHERE wordkey = ?");
mysqli_stmt_bind_param($stmt, 'i', $id);
$stmt->execute();
$stmt->bind_result($def);
while($stmt->fetch()) {
echo "here"; // for testing
$wordArray += $def;
//I will make a call to the js function here sending id, name and wordArray
}
//$stmt->close();
}
function select1 ($conn){
$stmt2 = $conn->prepare("SELECT id , name FROM words");
$stmt2->execute();
$stmt2->bind_result($id, $name);
while($stmt2->fetch()) {
select2 ($conn,$id ,$name);
}
}
?>
I want to ask question I have words table and def table. in def table i have multiple definitions for the same words.id. Is it possible to select them in one query statement ?
words table have
id , name
def table have
id, wordkey , definition
I want to retrieve name and for each name select all its definitions so that I will then call a javascript function (id, name, defArray) to display each name with the array of its definitions. I thought of doing it through 2 select statement, but the problem is the select2 function is not working. Please Help!