Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Web Development Software (https://www.askmehelpdesk.com/forumdisplay.php?f=468)
-   -   Problem with PHP script: FOR, WHILE and MYSQLI_FETCH_ARRAY (https://www.askmehelpdesk.com/showthread.php?t=803684)

  • Oct 28, 2014, 08:42 AM
    hsosaj
    Problem with PHP script: FOR, WHILE and MYSQLI_FETCH_ARRAY
    Hi, I have an PHP script that start like this:
    for ($x = 2; $x <= count($data->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.

  • All times are GMT -7. The time now is 08:06 PM.