I need to query different database for the entry. In this way I can get translation of the required word. I could use one table but I think it would be to complicated in this way. If I use mysqli_fetch_row there are no mistakes, but if I use mysqli_fetch_array and input words that I have in database, there are mistakes. So if I input the word Brief
Like
$wordGermanBrief
$verbGermanBrief
$pronounGermanBriefwordGermanBrief$_POST["wordGerman"]=Brief
Notice: Undefined index: wordGerman in C:\xampp\htdocs\topics\toknow\mysqli_use_result\mysqli_use_result.php on line 39 wordGerman$_POST["wordGerman"]=Brief
CREATE TABLE `germanverbs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`verbGerman` varchar(20) DEFAULT NULL,
`verbEnglish` varchar(20) DEFAULT NULL,
`PartOfSpeech` varchar(20) DEFAULT NULL,
`SingularFirst` varchar(20) DEFAULT NULL,
`SingularSecond` varchar(20) DEFAULT NULL,
`SingularThird` varchar(20) DEFAULT NULL,
`PluralFirst` varchar(20) DEFAULT NULL,
`PluralSecond` varchar(20) DEFAULT NULL,
`PluralThird` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
CREATE TABLE `germanpronouns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pronounGerman` varchar(20) DEFAULT NULL,
`pronounEnglish` varchar(20) DEFAULT NULL,
`PartOfSpeech` varchar(20) DEFAULT NULL,
`SingularFirst` varchar(20) DEFAULT NULL,
`SingularSecond` varchar(20) DEFAULT NULL,
`SingularThird` varchar(20) DEFAULT NULL,
`PluralFirst` varchar(20) DEFAULT NULL,
`PluralSecond` varchar(20) DEFAULT NULL,
`PluralThird` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
CREATE TABLE `germannouns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`wordGerman` varchar(20) DEFAULT NULL,
`wordEnglish` varchar(20) DEFAULT NULL,
`PartOfSpeech` varchar(20) DEFAULT NULL,
`Nominativ` varchar(60) DEFAULT NULL,
`Genetive` varchar(20) DEFAULT NULL,
`Dative` varchar(20) DEFAULT NULL,
`Accusative` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
index.php
<?php
$link = mysqli_connect("localhost","root","","dictionary");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$wordGerman = $_POST['wordGerman'];
$verbGerman = $_POST['wordGerman'];
$pronounGerman = $_POST['wordGerman'];
$query = <<<_SQL_
SELECT * FROM germannouns WHERE wordGerman ='$wordGerman';
SELECT * FROM germanverbs WHERE verbGerman ='$verbGerman';
SELECT * FROM germanpronouns WHERE pronounGerman ='$pronounGerman';
_SQL_;
echo '$wordGerman'.$wordGerman.'<br />'
.'$verbGerman'.$verbGerman.'<br />'
.'$pronounGerman'.$pronounGerman;
if(mysqli_multi_query($link, $query)){
do {
/* store first result set */
if($result = mysqli_use_result($link))
// while($row=mysqli_fetch_row($result)){
// printf("%s\n", $row[0]);
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC )){
echo $row["verbGerman"];
echo $row["wordGerman"];
echo $row["pronounGerman"];
}
mysqli_free_result($result);
/* print divider */
if(mysqli_more_results($link)){
printf("-----------------\n");
}
} while(mysqli_next_result($link));
}
/* close conncection */
mysqli_close($link);
?>
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search a word in German</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div style="margin" 100px auto 0; width: 300px;">
<form name="form1" id="form1" action="index.php" method="post">
<fieldset>
Enter German word<input type="text" name="wordGerman" placeholder="german word" />
<br />
<input type="submit" name="submit" value="submit" />
</fieldset>
</form>
</div>
</body>
</html>
I would be happy if you advise me, what I should do.