Jump to content

need some help


m4x3vo

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.