Du får lige hele mit script:
- $db->mysql_open();
- mysql_set_charset('utf8');
- $db->query("SELECT *, COUNT(tagsId) AS tagsCount FROM tutorials INNER JOIN tagsForTutorials ON tutorials.tutorialsId = tagsForTutorials.FK_tutorialsId INNER JOIN tags ON tagsForTutorials.FK_tagsId = tags.tagsId LEFT JOIN tutorialscomments ON tutorialscomments.FK_tutorialsId = tutorials.tutorialsId INNER JOIN members ON tutorials.tutorialsAuthor = members.membersId GROUP BY tutorialsId ORDER BY tutorialsId DESC");
- $result = $db->fetchAll();
-
- if(mysql_num_rows($db->query) == 0)
- {
- ?>
- <div class="and">
- <h3>Ingen resultater fundet</h3>
- <span>
- <p>
- Bloggen har endnu ikke nogle indlæg.<br />
- Kontakt mig for at foreslå nogle indlæg.
- </p>
- </span>
- <div class="clear"></div>
- </div>
- <?php
- }
- else
- {
- foreach($result as $row):
- $day = date("d", strtotime($row["tutorialsDate"]));
- $month = date("n", strtotime($row["tutorialsDate"]));
- $year = date("Y", strtotime($row["tutorialsDate"]));
-
- $months = array(01 => "januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december");
-
- $days = array("Monday" => "Mandag", "Tuesday" => "Tirsdag", "Wednesday" => "Onsdag", "Thursday" => "Torsdag", "Friday" => "Fredag", "Saturday" => "Lørdag", "Sunday" => "Søndag");
-
- $date = $month . "/" . $day . "/" . $year;
- $dateget = getdate(strtotime($date));
- ?>
- <div class="blo">
- <h3><?=$row["tutorialsName"]?></h3>
- <span>
- <ul>
- <li><img src="<?=$menu->menu()?>img/clock.gif" alt="date" />
- <?=$days[$dateget['weekday']]." d. ".$day." ".$months[$month].", ".$year?></li>
- <li><img src="<?=$menu->menu()?>img/comments.gif" alt="com" />
- <a href="<?=$menu->menu()?>tutorials/<?=$row["tutorialsId"]?>/#comments"><?=count($row["comId"])?> <?=(count($row["comId"]) == 1 ? 'Comment' : 'Comments')?></a></li>
- <li><img src="<?=$menu->menu()?>img/tag.gif" alt="tag" />
- <?php for($k=0;$k<$row["tagsCount"];$k++): echo '<a href="'.$menu->menu().'tutorials/tag/'.$row["tagsName"].'/">'.$row["tagsName"].'</a> '; endfor; ?></li>
- <li><img src="<?=$menu->menu()?>img/author.gif" alt="author" />
- <?php if($row["show"] == "1") echo $row["membersUsername"]; elseif($row["show"] == "2") echo $row["membersFornavn"]; else if($row["show"] == "3") echo $row["membersEfternavn"]; else if($row["show"] == "4") echo $row["membersFornavn"] . " " . $row["membersEfternavn"]; else if($row["show"] == "5") echo $row["membersEfternavn"] . " " . $row["membersFornavn"]; ?></li>
- </ul><br />
- <p>
- <?php
- $array1 = array("[img", "/]");
- $array2 = array("<img", "/>");
- $row["tutorialsText"] = str_replace($array1, $array2, $row["tutorialsText"]);
-
- echo (strlen($row["tutorialsText"]) > 200 ? strip_tags(substr($row["tutorialsText"], 0, 200) . "...") : strip_tags($row["tutorialsText"]));
- ?><br /><br />
-
- <a href="<?=$menu->menu()?>tutorials/<?=$row["tutorialsId"]?>/" class="more">Læs mere</a>
- </p>
- </span>
- <div class="clear"></div>
- </div>
- <?php
- endforeach;
- }
- $db->mysql_close();
For jeg ved ikke lige hvordan man skulle kunne smide en mysql_fetch_row ind i en for-løkke.