Jump to content

Got stuck with inner join in php/mysql, please help


Rebelfriik009

Recommended Posts

hi everyboy;

 
 1. mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
 2. Warning: Invalid argument supplied fo   foreach()
 
i want to join quoteText with author name and email. Thanks
 
    here are the tables
 
    author table (id, name, email)
 
    user_quotes table(id, City, quoteText)
    
   
Here are my code
 
    <?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']);}
   ?>
  <body>
   <?php foreach ($quotes as $quote):?>
   <form action="?deletequote" method="post">
   
   <?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; ?>
Link to comment
Share on other sites

Try changing  joke.id  in the query to just  id

 

If the error still persists then change change  $resultat = mysqli_query($db_connection, $requete);  to be

 $resultat = mysqli_query($db_connection, $requete) or trigger_error('SQL Error: ' . $db_connection->error);
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.