Home | Registrieren | Einloggen | Suchen | Aktuelles


Forum » PHP & MySQL » News-script Antworten
News-script

ketchxup
Feiertags-Poster


Beiträge: 38


Hi,

ab folgendes Problem : bin schon 3 wochen dabei an einem newssript zu basteln.
die struktur sollte so aussehen : News : Players News -> alle Spieler-->news title-->news
Injury News -> alle Verletzten
Manger News -> Mannager-->news title-->news
ich will es so anzeigen, dass erst die Kategorien angezeigt werden und beim "Klicken" die
Subkategorien dann die newseinträge (erst title und beschreibung.
Problem ist : ich weiss nicht wie ich anfangen sollte spricht die mysql structur...
die idee war 2 tabelle zu erstellen. die erste: "topic"...entspricht die kategorien...da tauchen schon die ersten problemen,denn ich müstte doch die 1.tabelle mit 2.tabelle (die news eintägre) verbinden, indem ich in tabelle 2 die id für tabelle 1 zuweise oder?

Wie würdet ihr das machen?
ers wäre nett wenn jemand mir helfen könnte!

Diese Nachricht wurde geändert von: ketchxup
  Profil   E-Mail   Editieren   Zitieren

Maxx
Otto-Normal-Poster


Beiträge: 87


servas,

struktur:
2 tabellen
->kategorien: name, id
->news: poster, title, datum, beitrag, katid

du weißt deinen ganzen kategorien eine ID zu.
so beim erstellen der news machst du dir eine Auswahlbox in der du die kats die du aus der datenbank auslesen lassen hast auswählen kannst.
Jedem als value die seite katid

wenn du jetzt alles erstellt hast schreibst du in die datenbank deine ganzen sachen : poster, title, datum, beitrag und die besagte Katid
wenn du nun die "navigation" gemacht hast, lässt du wieder aus der tabelle "kategorien" deine Id's auslesen, wenn das geschehen ist machst du dich an die newsausgabe, welche du dann mit "SELECT ..... WHERE `katid` = '$katid`"
die variable $katid ist die id der kategorie in welcher du dich befindest

also ich hoffe ich konnte dir das ein bissel erleichtern
wenn du fragen hast einfach schreiben

---
BoardSuche - PHP - Google

  Profil   Editieren   Zitieren

ketchxup
Feiertags-Poster


Beiträge: 38


ketchxup schrieb am 17.04.2005 18:52
Danke erstmal hat mir viel geholfen :

nur ich kann die kategorien index2.php nicht entsprechend weiterleiten---> viewnews.php


index2.php

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17:
 <?  include("config.php");//include the file to connect to the database

 $query_kat = "SELECT * FROM kategorien"; 
 $kat2 = mysql_query($query_kat) or die(mysql_error()); 
  $row_kat2 = mysql_fetch_assoc($kat2);        ?> 
  
  <html>  
  <head></head>  
  <title></title>   
  <body>  

<?php   do {    ?>  <table align="center">        
<td><a href="viewnews.php=<?php echo $row_kat2['id']; ?>">
<?php echo $row_kat2['name']?></a></td>  </table> 
 <?php  } while ($row_kat2 = mysql_fetch_assoc($kat2));  ?>  
 </body>     
 </html>       



viewnews.php
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12:
  <?  include("./config.php");//include the file to connect to the database
  
  $getnews = mysql_query("SELECT * FROM news WHERE `katid`=`$katid`");
      
while($r=mysql_fetch_array($getnews)){//while there are rows in the table
extract($r);//remove the $r so its just $variable     
		
  echo("<hr>  <font size=3>$title added on $datum</font>
  <font size=1>Posted by $poster</font>
  <font size=2>$beitrag</font><p>");    
  
  }  ?>


geht praktisch nur umd dir verlinkung


Diese Nachricht wurde geändert von: ketchxup
  Profil   E-Mail   Editieren   Zitieren

ketchxup
Feiertags-Poster


Beiträge: 38


ich weiss nicht ob ich die where bedinung an der richtige stelle habe

  Profil   E-Mail   Editieren   Zitieren

languitar
Foren-Team


Beiträge: 2795


Where sieht richtig aus. Im Zweifelsfall probieren und die Fehler abfangen. MySQL gibt sehr schön aus, was an deinem Query falsch ist, wenn du einen Fehler machst.

---
Take a look here!
Lichtblick - Einblick - Ausblick

  Profil   E-Mail   Website   Editieren   Zitieren

ketchxup
Feiertags-Poster


Beiträge: 38


wie meinst du das?

wie müsste ich eigentlich v. index2.php auf die news( viewnews.php) verlinken
<a href="viewnews.php=<?php echo $row_kat2['id']; ?>

und $row_kat2 ist...: $row_kat2 = mysql_fetch_assoc($kat2);

  Profil   E-Mail   Editieren   Zitieren

ketchxup
Feiertags-Poster


Beiträge: 38


hab normal rumgepastelt.. und die verlinkung sieht so aus "....viewnews.php?katid="
irgendetwas hab ich falsch gemacht weiß aber nicht was ...denn es fellt die id --> also viewnews.php?katid=1 oder 2

  Profil   E-Mail   Editieren   Zitieren

Maxx
Otto-Normal-Poster


Beiträge: 87


kann das sein das deine Datenbank leer is um mal dumm zu fragen??
wenn nein dann versuch mal so:

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10:
<?  include("config.php");

 $query_kat = "SELECT * FROM kategorien"; 
 $kat2 = mysql_query($query_kat) or die(mysql_error()); 
 $row_kat2 = mysql_fetch_assoc($kat2);       
 
 echo '<a href="viewnews.php?kadid"'.$row_kat2['id'].'">LINK</a>';
 ?>       


PS DEIN CODE IS SOWAS VON DUMM ZUSAMMENGESTELLT!!!!
das is 100% unübersichtlich und was soll immer das php auf und zu gemache??
nimm echo oder sowas ...

---
BoardSuche - PHP - Google

  Profil   Editieren   Zitieren

ketchxup
Feiertags-Poster


Beiträge: 38



Danke hat mir viel geholfen !!!!!!!!!

nun möchte ich die news in meinem Spielerprofil einbinden
genau so wie hier (ganz unten) Jens Lehman Profil

tabelle1(Spielerprofil)

profil-> id,title,text,born ...usw

tabelle2(news)
news:-> id,title,datum,beitrag,profid,katid


ich möchte einfach die news im Profil (profil.php) wo alle Spieler aufgelistet sind
einbinden.

e.g Latest News from "SpielerX" und das nämlich bei allen

hab mit "FROM news INNER JOIN profil ON news.profid = profil.id"
zwar ging es aber spieler ohne news werden nicht angezeigt und alles wiederholt sich.


so sieht die quelle aus!

profi.php

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: 
76: 
77: 
78: 
79: 
80: 
81: 
82: 
83: 
84: 
85: 
86: 
87: 
88: 
89: 
90: 
91: 
92: 
93: 
94: 
95: 
96: 
97: 
98: 
99: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: 
113: 
114: 
115: 
116: 
117: 
118: 
119: 
120: 
121: 
122: 
123: 
124: 
125: 
126: 
127: 
128: 
129: 
130: 
131: 
132: 
133: 
134: 
135: 
136: 
137: 
138: 
139: 
140: 
141: 
142: 
143: 
144: 
145: 
146: 
147: 
148: 
149: 
150: 
151: 
152: 
153: 
154: 
155: 
156: 
157: 
158: 
159: 
160: 
161: 
162: 
163: 
164: 
165: 
166: 
167: 
168: 
169: 
170: 
171: 
172: 
173: 
174: 
175: 
176: 
177: 
178: 
179: 
180: 
181: 
182: 
183: 
184: 
185: 
186: 
187: 
188: 
189: 
190: 
191: 
192: 
193: 
194: 
195:
<?
include("./config.php");//include the file to connect to the database
//kategorien mysql//********************************************************
$query_kat = "SELECT * FROM kategorien";                                  // 
$kat2 = mysql_query($query_kat) or die(mysql_error());                    //
$row_kat2 = mysql_fetch_assoc($kat2);                                     //
//***************************************************************************


//player profil mysql//********************************************************
$query_art = "SELECT * FROM profil"; 
$art = mysql_query($query_art) or die(mysql_error());                    //
$row_art = mysql_fetch_assoc($art);                                     //
//***************************************************************************



//player lsit/menu mysql//********************************************************
$query_dd = "SELECT * FROM profil"; 
$dd = mysql_query($query_dd) or die(mysql_error());                    //
$row_dd = mysql_fetch_assoc($dd);                                     //
//***************************************************************************

genau hier ist das problem

//player News mysql//********************************************************
$query_newspl = "SELECT * FROM news"; 
$newspl= mysql_query($query_newspl) or die(mysql_error());                    //
$row_newspl = mysql_fetch_assoc($newspl);                                     //
//***************************************************************************



?>
<html>
<head>
<link href="css/style01.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>



 



<body>
  
 <!-- Profil Scoll -->
   <form>
   <select name="staff_js" class="listmenu" onChange="goto_URL(this.form.staff_js)">
   <option value="">-- Please select --</option>
   <?php do {  ?>
  <option value="topic.php?id_art=<?php echo $row_dd['id_art']; ?>"><?php echo $row_dd['title_art']?>
  </option>
    <?php
} while ($row_dd = mysql_fetch_assoc($dd));
  $rows = mysql_num_rows($dd);
  if($rows > 0) {
      mysql_data_seek($dd, 0);
	  $row_dd = mysql_fetch_assoc($dd);
  }
?>
    </select></form>
  	
  <?php do { ?>
 
  <table width="745" height="392"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" >
  <!--DWLayoutTable-->
  <tr> 
    <td width="5" height="22"> </td>
    <td colspan="2" rowspan="3" valign="top"><table width="100" border="0" cellpadding="0" cellspacing="0" class="tb">
        <!--DWLayoutTable-->
        <tr> 
          <td width="64" height="95"> </td>
          <td width="64" valign="top"><img src="<?php echo $row_art['img']; ?>"></td>
        </tr>
      </table></td>
    <td width="36"> </td>
    <td width="450"> </td>
    <td width="1"></td>
    <td width="23"></td>
  </tr>
  <tr> 
    <td height="43"> </td>
    <td> </td>
    <td colspan="2" valign="top" class="tb"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tb">
        <!--DWLayoutTable-->
        <tr> 
          <td width="284" height="7"></td>
          <td width="65"></td>
          <td width="102"></td>
        </tr>
        <tr> 
          <td height="10"></td>
          <td rowspan="2" valign="top" class="title"><img src=" <?php echo $row_art['trickot']; ?>" width="36" height="29"  id="trickot"></td>
          <td></td>
        </tr>
        <tr> 
          <td height="20" valign="top" class="title"><a href="topic.php?id_art=<?php echo $row_art['id_art']; ?>"   id="arttile" dir="arttile"><?php echo $row_art['title_art']; ?></a></td>
          <td></td>
        </tr>
      </table></td>
    <td> </td>
  </tr>
  <tr> 
    <td height="30"></td>
    <td> </td>
    <td colspan="2" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tb">
        <!--DWLayoutTable-->
        <tr> 
          <td width="100%" height="28" valign="top" class="textcont"><p><?php echo $row_art['description_art']; ?><a   id="aprofil" href="../../Templates/topic.php?id_art=<?php echo $row_art['id_art']; ?>"> 
              </a></p></td>
          <td width="1" rowspan="2"> </td>
          <td width="1" rowspan="2"></td>
        </tr>
        <tr> 
          <td height="29" valign="top" class="textcont"><?php echo $row_art['title']; ?>
		 
		  </td>
        </tr>
        <tr> 
          <td height="116" valign="top" class="playerlink" ></td>
          <td valign="top" class="playerlink" ></td>
          <td></td>
        </tr>
        <tr> 
          <td height="1"></td>
          <td><img src="../../spacer.gif" alt="" width="1" height="1"></td>
          <td><img src="../../spacer.gif" alt="" width="1" height="1"></td>
        </tr>
      </table></td>
    <td></td>
  </tr>
  <tr> 
    <td height="109"></td>
    <td width="203" rowspan="2" valign="top" class="profil"><p></p>
      <p><span class="proftext1"> Name:</span><span class="proftext2"> <?php echo $row_art['full_name']; ?></span>

        <span class="proftext1">Born:</span><span class="proftext2"> <?php echo $row_art['Born']; ?></span>

        <span class="proftext1">Position</span><span class="proftext2">: <?php echo $row_art['Position']; ?></span>

        <span class="proftext1">Appearence:</span> <span class="proftext2"><?php echo $row_art['appearences']; ?></span>

        <span class="proftext1">Minutes Played:</span><span class="proftext2"> 
        <?php echo $row_art['minutes_played']; ?></span>

        <span class="proftext1">Joined Arsenal:</span> <span class="proftext2"><?php echo $row_art['joined_arsenal']; ?></span>

        <span class="proftext1">Previous Club(s):</span><span class="proftext2"><?php echo $row_art['previous_club(s)']; ?>

        </span></p>
      <p><a href="topic.php?id_art=<?php echo $row_art['id_art']; ?>" class="playerlink">Full 
        Profil</a><img src=" <?php echo $row_art['trickot']; ?>" width="36" height="19" id="abild"> 
      </p></td>
    <td width="27" rowspan="2" valign="top" class="profbar"><!--DWLayoutEmptyCell--> </td>
  </tr>
  <tr> 
    <td height="2"></td>
    <td></td>
    <td rowspan="3"> </td>
    <td></td>
    <td></td>
  </tr>
  <tr> 
    <td height="40"></td>
  </tr>
</table>
 <?php } while ($row_art = mysql_fetch_assoc($art)); ?>

 
 
 </body>
</html>
</SCRIPT> 
<script language="JavaScript">
		function goto_URL(object)
		{
			window.location.href = object.options[object.selectedIndex].value;
		}
</script>



<?php mysql_free_result($art);?>



P.s diese auf und zu gemache..: ich wüsste einfach nicht wie es anders gehen sollte da ich html-tags benutze.....

Diese Nachricht wurde geändert von: ketchxup
  Profil   E-Mail   Editieren   Zitieren

Maxx
Otto-Normal-Poster


Beiträge: 87


wenn die ohne news nicht angezeigt werden mach eine abfrage:

1: 
2: 
3: 
4: 
5: 
6:
if($mysql_num_rows($newspl) == "0"){
  echo 'keine News vorhanden';
  // und dann ggf. noch ein exit();
}


---
BoardSuche - PHP - Google

  Profil   Editieren   Zitieren

ketchxup
Feiertags-Poster


Beiträge: 38


mal ne blööde Frage wo sollte ich es am besten einbauen
oder muss ich es mit etwas ersetzen

  Profil   E-Mail   Editieren   Zitieren

Maxx
Otto-Normal-Poster


Beiträge: 87


nein das musst du vor der ausgabe des "NewsTeiles" einfügen,
d.h. befor die news ausgegeben werden

---
BoardSuche - PHP - Google

  Profil   Editieren   Zitieren
 

Antworten
Nach oben