So when I add a product, an id is assigned and a file is created with the product id, eg 1000.php. I don't know how to call it in the product.php file to be included:
I know what I did in the code pasted below is wrong but I don't know how to make it call the 1000.php file by extracting the id from sql first and then include it in the same file. Any advice?
<?php
function between($start, $end, $string) {
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
$pid = $_GET['id'];
$pid = trim($pid);
include('php/config.php');
$sql = "SELECT * FROM products WHERE pid='".$pid."'";
$result = $config->query($sql);
$num_row = mysqli_num_rows($result);
if($num_row == 1 ) {
$row = mysqli_fetch_array($result);
extract($row);
$display = 1; } else { $display = 0; }
include('".$pid.".php');