Question: ```
I have a table with: 
 tbl_Category
  Id        |           Name            |       ParentID

  1                 Category 1                      0
  2                 Category 2                      0
  3                 Subcategory 11                  1
  4                 Subcategory 12                  1
  5                 Subcategory 21                  2
  6                 Subcategory 211                 5
  7                 Subcategory 22                  2
.........

How do I return it in a dropdownlist in the below format:

Category 1
--Subcategory 11
--Subcategory 12
--Subcatgory 13
Category 2
--Subcategory 21
----Subcategory 211
----Subcategory 212
--Subcategory 22
--Subcatgory 23
Category 3
--Subcategory 31
--Subcategory 32

```

Answer: 
You can use **session**. base on your code you can try this:
In start page (ddd.php) you have to set your session values.

```
<?php
  session_start();
  $_SESSION["writer"] = $_POST["writter"];
?>
...

```

in other page use your session values as e.g:

```
<?php
  session_start();
  ...
  echo $_SESSION["writer"];
?>

```

Note that **unset** and **destroy** your session at the end off your work.

```
<?php
    // remove all session variables
    session_unset();

    // destroy the session
    session_destroy(); 
?>

```
You can set a cookie

```
$value = 'something from somewhere';
setcookie("TestCookie", $value);

```

and get the value:

```
echo $_COOKIE["TestCookie"];

```

You can also use sessions:

```
session_start();

// Set session variables
$_SESSION["TestSession"] = $value;

// Get session
echo $_SESSION["TestSession"];

```

You'd better use a framework like [Laravel](https://laravel.com/) that can help you handle sessions, forms, redirect with values etc.

You can find the [documentation](http://php.net/manual/en/function.setcookie.php) on php.net