Daten via mysql auslesen und Kategoriert ausgeben. aber wie? mit Group by?
Moin!
Ich else meine daten aus meiner datenbank aus in Abhängikeit von einer WHERE clause.
" WHERE category = '$cat' ";
Ich Möchte die Daten dann so Ausgeben das ich folgendes Muster erhalte:
Kategorie1
Daten1
Daten2
Kategorie2
Daten1
Daten2
Mein bisheriger Code sieht so aus und nun weis ich nicht mehr weiter
:
Ich else meine daten aus meiner datenbank aus in Abhängikeit von einer WHERE clause.
" WHERE category = '$cat' ";
Ich Möchte die Daten dann so Ausgeben das ich folgendes Muster erhalte:
Kategorie1
Daten1
Daten2
Kategorie2
Daten1
Daten2
Mein bisheriger Code sieht so aus und nun weis ich nicht mehr weiter
:|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
<?php
// Videomanagmentsystem
// by Butcher
include('config.php');
$sql2 = mysql_query("SELECT * FROM " .$db_prefix. "daten ORDER by category ASC");
while($daten = mysql_fetch_array($sql2))
{
$category = $daten['category'];
}
$sql = mysql_query("SELECT * FROM " .$db_prefix. "daten WHERE category = '$cat' ORDER by vid DESC") or die (mysql_error());
while($videos = mysql_fetch_array($sql))
{
$vid = $videos ['vid'];
$title = $videos['title'];
$description = $videos['description'];
$hits = $videos['hits'];
$comments = $videos['comments'];
$description_short = substr($description, 0,50) . " <a href=\"videos_comments.php?vid=$vid\"> [ ... mehr ]</a>";
$show['videoslist'] .= "
<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"57\" height=\"25\" valign=\"top\"><table width=\"57\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"57\" height=\"25\" valign=\"top\">#ID: $vid</td>
</tr>
</table> </td>
<td width=\"100%\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"50%\" height=\"25\" valign=\"top\"> <a href=\"videos_comments.php?vid=$vid\">$title</a></td>
<td width=\"456\" valign=\"top\"> $description_short</td>
</tr>
</table>
</td>
<td width=\"163\" valign=\"top\"><div align=\"right\">
<table width=\"163\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"163\" height=\"25\" valign=\"top\">Kommentare: $comments </td>
</tr>
</table>
</div></td>
<td width=\"100\" valign=\"top\"><div align=\"right\">
<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"100\" height=\"25\" valign=\"top\">Hits: $hits </td>
</tr>
</table>
</div></td>
</tr>
</table>
";
}
print $show['videoslist'];
?>
Könnt ihr mir helfen das Problem zu lösen?
|
www.butcher.info.ms
RE: Daten via mysql auslesen und Kategoriert ausgeben. aber wie? mit Group by?
Muharr ... Dreamweaver 
probier mal so:

probier mal so:
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
// Videomanagmentsystem
// by Butcher
include('config.php');
$sql2 = mysql_query("SELECT * FROM " .$db_prefix. "daten ORDER by category ASC");
while($daten = mysql_fetch_array($sql2))
{
$category = $daten['category'];
$sql = mysql_query("SELECT * FROM " .$db_prefix. "daten WHERE category = '$cat' ORDER by vid DESC") or die (mysql_error());
while($videos = mysql_fetch_array($sql))
{
$vid = $videos ['vid'];
$title = $videos['title'];
$description = $videos['description'];
$hits = $videos['hits'];
$comments = $videos['comments'];
$description_short = substr($description, 0,50) . " <a href=\"videos_comments.php?vid=$vid\"> [ ... mehr ]</a>";
echo"
<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"57\" height=\"25\" valign=\"top\"><table width=\"57\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"57\" height=\"25\" valign=\"top\">#ID: $vid</td>
</tr>
</table> </td>
<td width=\"100%\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"50%\" height=\"25\" valign=\"top\"> <a href=\"videos_comments.php?vid=$vid\">$title</a></td>
<td width=\"456\" valign=\"top\"> $description_short</td>
</tr>
</table>
</td>
<td width=\"163\" valign=\"top\"><div align=\"right\">
<table width=\"163\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"163\" height=\"25\" valign=\"top\">Kommentare: $comments </td>
</tr>
</table>
</div></td>
<td width=\"100\" valign=\"top\"><div align=\"right\">
<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"100\" height=\"25\" valign=\"top\">Hits: $hits </td>
</tr>
</table>
</div></td>
</tr>
</table>";
}
}
|



Des funzt irgendwie nit 