<?php 

	session_start();
	include_once('../../db/saucerer.php');

//Update All

    if(isset($_POST['submit']))  
    {  

    $id = $_POST['id'];

    for($i=0;$i<count($id);$i++){
        $id_id = $id[$i];


$sql = "SELECT * FROM listings WHERE id = '$id_id'"; 

$result = $conn->query($sql);  

while($row = mysqli_fetch_array($result)) { 

	$title = $row['title'];

    }

    $a="'";
    $b="";
    $title1 = str_replace($a, $b, strtolower($title));

    $x=" ";
    $y="-";
    $url = str_replace($x, $y, $title1);


    $in_ch=mysqli_query($con,"UPDATE listings SET  url = '$url' WHERE id = '$id_id'");  

	}
    
    if($in_ch==1)  
       {  
        $_SESSION['success'] = "Success";
       }  
    else  
       {  
        $_SESSION['error'] = "Error";
       }

      
    }  

	header('location: ../?creator=1');
    ?>