General discussion
Got stuck with inner join in php/mysql
php

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()

    <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"smile {
    $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'smile; ?>

<input type="hidden" name="id" value="<?php echo $quote['id'];?>">

<?php echo htmlspecialchars($quote['name'], ENT_QUOTES, 'UTF-8'smile; ?>

<?php echo htmlspecialchars($quote['email'], ENT_QUOTES, 'UTF-8'smile; ?>

<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() &amp;lt;p&amp;gt;here are the tables author table (id, name, email) user_quotes table(id, City, quoteText) &amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;Here are my code&amp;lt;/p&amp;gt; &amp;lt;?php if ($_SERVER[&quot;REQUEST_METHOD&quot;]==&quot;POST&quot;) { $id_select = $_POST[&#039;id&#039;]; $action = &quot;DELETE FROM user_quotes WHERE id = &#039;$id_select&#039;&quot;; $requet= mysqli_query($db_connection, $action); } $requete = &quot;SELECT joke.id, quoteText, name, email FROM user_quotes INNER JOIN author ON authorID = author.id&quot;; $resultat = mysqli_query($db_connection, $requete); while ($rows = mysqli_fetch_assoc($resultat)) { $quotes []= array(&#039;id&#039; =&amp;gt;$rows[&#039;id&#039;], &#039;text&#039; =&amp;gt;$rows[&#039;quoteText&#039;] &#039;name&#039;=&amp;gt;$rows[&#039;name&#039;], &#039;email&#039;=&amp;gt;$rows[&#039;email&#039;]);} ?&amp;gt; &amp;lt;p&amp;gt;&amp;lt;body&amp;gt;&amp;lt;/p&amp;gt; &amp;lt;?php foreach ($quotes as $quote):?&amp;gt; &amp;lt;form action=&quot;?deletequote&quot; method=&quot;post&quot;&amp;gt; &amp;gt; &amp;lt;p&amp;gt; &amp;lt;?php echo htmlspecialchars($quote[&#039;text&#039;], ENT_QUOTES, &#039;UTF-8&#039;); ?&amp;gt; &amp;lt;input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;&amp;lt;?php echo $quote[&#039;id&#039;];?&amp;gt;&quot;&amp;gt; &amp;lt;?php echo htmlspecialchars($quote[&#039;name&#039;], ENT_QUOTES, &#039;UTF-8&#039;); ?&amp;gt; &amp;lt;?php echo htmlspecialchars($quote[&#039;email&#039;], ENT_QUOTES, &#039;UTF-8&#039;); ?&amp;gt; &amp;lt;input type=&quot;submit&quot; value=&quot;Delete&quot;&amp;gt; &amp;lt;/p&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;?php endforeach; ?&amp;gt;
173
0
1
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft