PHP export from MySQL into CSV
I need to export data from MySQL to CSV but from specific ID. Table contains ID, ParentID and Name and here is code which exports all records: <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "databasename"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $index = array(); $num = 0; $sql = "SELECT NAME, ID, PARENTID from tablename"; $result = $conn->query($sql); while($row = $result->fetch_array(MYSQLI_ASSOC)){ $rows[] = $row;