hi everyboy,
I am trying to work with inner join in php/mysql. to associate author with their quotes in the display
- mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
Warning: Invalid argument supplied fo foreach()
<p>here are the tables
author table (id, name, email)
user_quotes table(id, City, quoteText)
</p>
<p>Here are my code</p>
<?php
if ($_SERVER["REQUEST_METHOD"]=="POST"
{
$id_select = $_POST['id'];
$action = "DELETE FROM user_quotes WHERE id = '$id_select'";
$requet= mysqli_query($db_connection, $action);
}
$requete = "SELECT joke.id, quoteText, name, email FROM user_quotes INNER
JOIN author ON authorID = author.id";
$resultat = mysqli_query($db_connection, $requete);
while ($rows = mysqli_fetch_assoc($resultat)) {
$quotes []= array('id' =>$rows['id'], 'text' =>$rows['quoteText']
'name'=>$rows['name'], 'email'=>$rows['email']);}
?>
<p><body></p>
<?php foreach ($quotes as $quote):?>
<form action="?deletequote" method="post">
<p>
<?php echo htmlspecialchars($quote['text'], ENT_QUOTES, 'UTF-8'
; ?>
<input type="hidden" name="id" value="<?php echo $quote['id'];?>">
<?php echo htmlspecialchars($quote['name'], ENT_QUOTES, 'UTF-8'
; ?>
<?php echo htmlspecialchars($quote['email'], ENT_QUOTES, 'UTF-8'
; ?>
<input type="submit" value="Delete">
</p>
</form>
<?php endforeach; ?>
hi everyboy,
I am trying to work with inner join in php/mysql. to associate author with their quotes in the display
1. mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
2. Warning: Invalid argument supplied fo foreach()
&lt;p&gt;here are the tables
author table (id, name, email)
user_quotes table(id, City, quoteText)
&lt;/p&gt;
&lt;p&gt;Here are my code&lt;/p&gt;
&lt;?php
if ($_SERVER["REQUEST_METHOD"]=="POST") {
$id_select = $_POST['id'];
$action = "DELETE FROM user_quotes WHERE id = '$id_select'";
$requet= mysqli_query($db_connection, $action);
}
$requete = "SELECT joke.id, quoteText, name, email FROM user_quotes INNER
JOIN author ON authorID = author.id";
$resultat = mysqli_query($db_connection, $requete);
while ($rows = mysqli_fetch_assoc($resultat)) {
$quotes []= array('id' =&gt;$rows['id'], 'text' =&gt;$rows['quoteText']
'name'=&gt;$rows['name'], 'email'=&gt;$rows['email']);}
?&gt;
&lt;p&gt;&lt;body&gt;&lt;/p&gt;
&lt;?php foreach ($quotes as $quote):?&gt;
&lt;form action="?deletequote" method="post"&gt;
&gt; &lt;p&gt;
&lt;?php echo htmlspecialchars($quote['text'], ENT_QUOTES, 'UTF-8'); ?&gt;
&lt;input type="hidden" name="id" value="&lt;?php echo $quote['id'];?&gt;"&gt;
&lt;?php echo htmlspecialchars($quote['name'], ENT_QUOTES, 'UTF-8'); ?&gt;
&lt;?php echo htmlspecialchars($quote['email'], ENT_QUOTES, 'UTF-8'); ?&gt;
&lt;input type="submit" value="Delete"&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;?php endforeach; ?&gt;