Problem With Php Script: For, While And Mysqli_Fetch_Array
Hi, I have an PHP script that start like this:
for ($x = 2; $x sheets[0]["cells"]); $x++) {
$familia = $data->sheets[0]["cells"][$x][1];
$subfamilia = $data->sheets[0]["cells"][$x][2];
$categoria = $data->sheets[0]["cells"][$x][3];
$subcategoria = $data->sheets[0]["cells"][$x][4];
$marca = $data->sheets[0]["cells"][$x][5];
$serie = $data->sheets[0]["cells"][$x][6];
$referencia = $data->sheets[0]["cells"][$x][7];
Then I need to insert values like this:
$re_s_mar = mysqli_query($dbc, "SELECT `id`, `marca` FROM `psm_gescom_articulos_marcas` WHERE `marca` = '$marca' LIMIT 0,1");
while($row_s_mar = mysqli_fetch_array($re_s_mar)) {
$id_mar = $row_s_mar['id'];
$mar_mar = $row_s_mar['marca'];
if(empty($mar_mar)){
$res_i_mar = mysqli_query($dbc, "INSERT INTO `psm_gescom_articulos_marcas` (`marca`) VALUES ('$marca')");
if(mysqli_affected_rows($dbc)>0){$rows = 1;}
}
}
But don´t let me do it, Just insert the fisrt value or none.