Liebe Leut,
irgendwie ist mein letztes Posting nicht wirklich gelungen. Also nochmals der Versuch.
Ich habe 2 Tabellen:
Links
- LinkID
- LinkName
- LinkHref
- LinkSectionID
- LinkAdder
- LinkAdderMail
- LinkApproved
und
LinkSections
- SectionID
- SectionName
- SectionApproved
Nun möchte ich auf meiner PHP seite alle Links aufzeigen, nach LinkSection sortiert. Dabei sollen die LinkSection als Block dargestellt werden, die per JS ein/ausgeblendet werden sollen (Das JS Feature funzt -> kein Problem)
Ich dachte, dass ich mit der do - while Anweisung eine äußere Schleife bastle, welche die verhandenen Sectionen behandelt.
Dabei habe ich einfache SQL-Abfrage erstellt, welche die LinkSections abfragt
PHP-Code:
mysql_select_db($database_eluni, $eluni);
$query_getSections = "SELECT LinkSections.LinkSectionID, LinkSections.SectionName FROM LinkSections WHERE LinkSections.SectionApproved =1";
$getSections = mysql_query($query_getSections, $eluni) or die(mysql_error());
$row_getSections = mysql_fetch_assoc($getSections);
$totalRows_getSections = mysql_num_rows($getSections);
Dazu die passende äußere Schleife:
HTML-Code:
<table id='Tabellenkopf'>
<tr>
<td>LinkName</td>
<td>Send by</td>
</tr>
</table>
<?php do {
echo $row_getSections['SectionName'];
call_user_func(getDectionLinks, $row_getSections['SectionID']);
<?php do {
<table id='Tabellenzeile'>
<tr>
<td><?php echo $row_getSectionLinks['LinkHref']; ?></td>
<td>mailto:<?php echo $row_getSectionLinks['LinkAdderMail']; ?></td>
</tr>
</table>
<?php } while ($row_getSectionLinks = mysql_fetch_assoc($getSectionLinks)); ?>
<?php } while ($row_getSections = mysql_fetch_assoc($getSections)); ?>
Jetzt möchte ich aber, dass in der
Tabellenzeile nur die Links mit dem Bezug zum aktuellen LinkSection gewählt werden. Dafür habe ich eine Funtion geschrieben, welche bei jedem Durchlauf eine SQL Abfrage starten sollen.
Die Function lautet:
PHP-Code:
function getSectionLinks($id) {
mysql_select_db($database_eluni, $eluni);
$query_getSectionLinks = "SELECT * FROM links Inner Join LinkSections ON links.linkSection = LinkSections.linksectionID
WHERE links.approved = '1' AND links.approved = '1' AND LinkSections.linksectionID = '$id'
ORDER BY links.linkSection Asc";
$getSectionLinks = mysql_query($query_getSections, $eluni) or die(mysql_error());
$row_getSectionLinks = mysql_fetch_assoc($getSectionLinks);
$totalRows_getSectionLinks = mysql_num_rows($getSectionLinks);
}
Die JS Sachen habe ich weggelassen, da der Beitrag ohnehin recht groß ist ;-)).
Ich kriege leider das script nicht zum Laufen. Die Schleife allein ohne die Function klappt ohne zu mucken.
Logikfehler? Falscher Befehl??
Wer kann mir bei diesem Problem helfen???
Allen nochmals vielen Dank und Gruß
Daniel