2021-03-30 10:52:22 +02:00
< ? php
ini_set ( 'display_errors' , 1 );
ini_set ( 'display_startup_errors' , 1 );
error_reporting ( E_ALL );
$root = realpath ( $_SERVER [ " DOCUMENT_ROOT " ]);
2021-03-30 16:26:55 +02:00
include ( " $root /vendor/erusev/parsedown/Parsedown.php " );
2021-03-30 10:52:22 +02:00
require " $root /database/credentials.php " ;
// Connect the database
try {
$db = new PDO ( " mysql:host= $host ;dbname= $database ;charset=utf8 " ,
$user ,
$password ,
array ( PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION
));
} catch ( Exception $e ){
die ( " Error : " . $e -> getMessage ());
}
$req = $db -> prepare ( 'SELECT * FROM `categories`' );
$req -> execute ();
$rows = $req -> fetchAll ( PDO :: FETCH_ASSOC );
2021-03-30 16:26:55 +02:00
$Parsedown = new Parsedown ();
2021-03-30 10:52:22 +02:00
?>
2021-04-20 17:05:13 +02:00
< h3 >< ? = _ ( 'Categories' ) ?> </h3>
2021-03-30 10:52:22 +02:00
< table id = " categories " >
< thead >
< tr >
2021-04-20 17:05:13 +02:00
< th scope = " col " >< ? = _ ( 'Title' ) ?> </th>
< th scope = " col " >< ? = _ ( 'Description' ) ?> </th>
2021-03-30 10:52:22 +02:00
</ tr >
</ thead >
< tbody >
< ? php
foreach ( $rows as $row ) {
2021-03-30 16:26:55 +02:00
?>
< tr >
2021-04-05 15:37:12 +02:00
< td >< a href = " topics/?cat=<?= $row['id'] ?> " >< ? = $row [ 'cat_name' ] ?> </a></td></p>
2021-03-30 16:26:55 +02:00
< td >< ? = $Parsedown -> text ( $row [ 'cat_description' ]) ?> </td>
</ tr >
2021-03-30 10:52:22 +02:00
< ? php
}
?> </tbody>
</ table >
2021-04-20 17:05:13 +02:00
< h3 >< ? = _ ( " Create a category " ) ?> </h3>
2021-03-30 10:52:22 +02:00
< form action = " createcategory.php " method = " post " >
2021-04-20 17:05:13 +02:00
< label for = " title " >< ? = _ ( 'Category title' ) ?> </label>
< input type = " text " id = " title " name = " title " placeholder = " <?=_('Enter a name for the new category..')?> " required >
< label for = " description " >< ? = _ ( 'Category description' ) ?> </label>
< textarea name = " description " id = " description " cols = " 30 " rows = " 5 " placeholder = " <?=_('Enter a description for the new category (support Markdown)..')?> " required ></ textarea >
< input type = " submit " value = " <?=_('submit')?> " name = " submit " >< input type = " reset " value = " <?=_('reset')?> " >
2021-03-30 10:52:22 +02:00
</ form >