reverse List

master
Helge 2022-01-09 22:05:20 +01:00
parent e56d62d2fa
commit 907d4c8f22
1 changed files with 13 additions and 8 deletions

View File

@ -53,17 +53,22 @@ class dbLinkHandler
]);
}
public function getLinkList()
public function getListReverse()
{
// Mit verschachtelten Arrays optimieren!! Array schlüssel id enthält array mit schlüssel link_id, link_name, etc (repräsentiert datensatz)
$list = array();
$sql = "SELECT * FROM link ORDER BY link_id DESC";
return $this->pdo->query($sql);
}
public function getList()
{
// Mit verschachtelten Arrays optimieren!! Array schlüssel id enthält array mit schlüssel link_id, link_name, etc (repräsentiert datensatz)
$list = array();
$sql = "SELECT * FROM link";
foreach ($this->pdo->query($sql) as $row)
{
$list[$row['link_name']] = $row['link_url'];
}
return $list;
return $this->pdo->query($sql);
}
}
@ -74,9 +79,9 @@ $link1=new Link("cloud.therealblue.de", "https://cloud.therealblue.de");
$db->saveLink($link1);
foreach($db->getLinkList() as $url => $name)
foreach ($db->getListReverse() as $link)
{
echo '<a href="'.$url.'" target="_blank">'.$name.'</a><br>';
echo $link['link_id'].': <a href="'.$link['link_url'].'" target="_blank">'.$link['link_name'].'</a><br>';
}
?>