Jump to content

Complex SELECT


matthewst

Recommended Posts

Sorry barand I'm not that smart. I only need to display the "1,2,3's" (dates) for this query, not the a's and b's.

The problem I'm having is I need to display dates from records with the same $id.

 

Example table:

id | date

a | 1

a | 1

a | 2

b | 7

a | 3

 

I need displayed like this:

(for the a's)

1,1,2,3

 

$query_dates="SELECT action FROM table_1 WHERE id=$id AND action=208"; 
$result_dates=mysql_query($query_dates); 
while ($row_dates = mysql_fetch_assoc($result_dates)) 
{ 
$action = $row_dates['action']; 
} 
if ($action){
$Get_Copy = mysql_query("SELECT * FROM tabel_2 WHERE order_id='$id'", $db_link);
while($pics = mysql_fetch_array($Get_Copy)) { 
$id = $pics['ord_id'];
$des_date = $pics['ord_date'];
}
if ($des_date != ""){
$des_date = substr($des_date, 4, 2).'/'.substr($des_date, 6, 2).'/'.substr($des_date, 0, 4);
}
echo "<td align='center' valign='top' width='60'><font size='-2'>$des_date<br></font></td>";
$des_date = ""; 
}

Link to comment
https://forums.phpfreaks.com/topic/96984-complex-select/#findComment-497007
Share on other sites

I just had to move some stuff around.

 

Thanks Everyone!

 

$query_dates="SELECT action FROM table_1 WHERE id=$id AND action=208"; 
$result_dates=mysql_query($query_dates); 
while ($row_dates = mysql_fetch_assoc($result_dates)) 
{ 
    $action = $row_dates['action']; 
} 
if ($action){
    $Get_Copy = mysql_query("SELECT * FROM tabel_2 WHERE order_id='$id'",       $db_link);
    while($pics = mysql_fetch_array($Get_Copy)) { 
        $id = $pics['ord_id'];
        $des_date = $pics['ord_date'];
        
        if ($des_date != ""){
            $des_date = substr($des_date, 4, 2).'/'.substr($des_date, 6, 2).'/'.substr($des_date, 0, 4);
        }

        echo "<td align='center' valign='top' width='60'><font size='-2'>$des_date<br></font></td>";
        $des_date = "";

    }

}

Link to comment
https://forums.phpfreaks.com/topic/96984-complex-select/#findComment-497634
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.