tomaszko Posted February 8, 2011 Share Posted February 8, 2011 Hello, today's problem - my table only shows recipent which are in group, not ones without a group. I think I made wrong query to database. $q = "SELECT * FROM recipent, group WHERE group.id_group=recipent.group_id"; $w = mysql_query($q) or die ('Error: '. mysql_error()); ?> <hr /> <table method='get'> <tr><th></th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=imie">Imię</a> </th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=nazwisko">Nazwisko</a> </th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=telefon">Telefon</a></th><th><a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=mail">Mail</a> </th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=miasto">Miasto</a></th><th><a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=ulica">Ulica</a> </th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=kodpocztowy">Kod Pocztowy</a></th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=grupa_id">Grupa</a></th></tr> <?php while ($record = mysql_fetch_assoc($w)) { ?> <tr> <td><input type="checkbox"/></td> <td><?php echo $rekord['imie'];?></td> <td><?php echo $rekord['nazwisko'];?></td> <td><?php echo $rekord['telefon']; ?></td> <td><?php echo $rekord['mail'];?></td> <td><?php echo $rekord['miasto'];?></td> <td><?php echo $rekord['ulica']; ?></td> <td><?php echo $rekord['kodpocztowy']; ?></td> <td><?php echo $rekord['nazwa']; ?></td> <td><a href="odbiorcy_edytuj.php?akcja=edytuj&id_klient=<?php echo $rekord['id_klient'];?>"><?php echo "Edytuj"?></a></td> <td><a href="odbiorcy_usun.php?akcja=usun&id_klient=<?php echo $rekord['id_klient'];?>"><?php echo "Usuń"?></a></td> </td> </tr> <?php } ?> </table> And code bellow is cell where group name is displayed. <td><?php echo $rekord['nazwa']; ?></td> Link to comment https://forums.phpfreaks.com/topic/227078-listing-recipents-with-groups/ Share on other sites More sharing options...
fenway Posted February 13, 2011 Share Posted February 13, 2011 You need a LEFT JOIN. Link to comment https://forums.phpfreaks.com/topic/227078-listing-recipents-with-groups/#findComment-1173591 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.