Jump to content

Recommended Posts

Ah it did work.

Is there a way to simplify my code, I want the query inside the while statement ($querytt) to be joined in the same query outside the statement ($queryt)...

both user_ach and ach can be joined on ach_id and id...

 

gah i know the code is messy xD

 

$queryt = "SELECT a.ach_id FROM user_ach a INNER JOIN user_ach b ON a.ach_id = b.ach_id AND a.user_id = 1 AND b.user_id = 15";
$resultt = mysql_query($queryt) or die(mysql_error());
while ($kkk = mysql_fetch_assoc($resultt)){
$lol = $kkk['ach_id'];
$querytt = "SELECT * FROM ach WHERE id = '$lol'";
$resulttt = mysql_query($querytt) or die(mysql_error());
$kkkk = mysql_fetch_assoc($resulttt);
$image = $kkkk['image'];
echo "<img src='$image'></img>"; }

 

Link to comment
https://forums.phpfreaks.com/topic/165528-need-some-help/#findComment-873860
Share on other sites

should be something like this:

$queryt = "SELECT c.image
    FROM user_ach a 
      INNER JOIN user_ach b 
        ON a.ach_id = b.ach_id 
      LEFT JOIN ach c
        ON a.ach_id = c.id
    WHERE a.user_id = 1 AND b.user_id = 15
";
$resultt = mysql_query($queryt) or die(mysql_error());
while($kkk = mysql_fetch_assoc($resultt)){
  $image = $kkk['image'];
  echo "<img src='$image'></img>";
}

Link to comment
https://forums.phpfreaks.com/topic/165528-need-some-help/#findComment-874504
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.