Jump to content
php.lv forumi

mysql: GROUP_CONCAT


sandis_m

Recommended Posts

Kā vislabāk un ērtak ieglabāt iekš GROUP_CONCAT 2 vērtības (ja tas ir iespejas. patreiz sanāk tikai ar vienu) (Un kā vispār to izarīt)

 

<?php
$sql = mysql_query("SELECT galv.*, undegalv.*, COUNT(undergalv.id) as `skaits`, GROUP_CONCAT(undergalv.sdescription SEPARATOR '|') AS viskas
               	FROM `galvenais` galv, `undergalvenais` subtas
               	WHERE  galv.id=undergalv.tid
               	GROUP BY galv.id
               	ORDER BY galv.id DESC, undergalv.id DESC");

while($data = mysql_fetch_array($sql)){
?>
   Galvenais: <?php echo $data["name"];?>:<br/>

   Zem galvena: <br/>

   <?php
   if(!empty($data["viskas"])){
   	$viskas= explode('|', $data['viskas']);    
   	foreach($viskas as $apraksts){
  	     echo $apraksts; // izvada aprakstu. viss ok. bet vajag, lai panem velvienu undergalvenais lauku - status.
       }
   }
}
?>

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...