Does any return value stop a cycle?

1

I have the following code, which I have a while that repeats me N quantity of products purchased from a database, in a td I have a select that is filled with the total products in my database, selecting the one that I bought , the problem is that when you show the first record, you leave the cycle and you do not keep showing me the others.

while ($RowProd = mssql_fetch_array($RProd)) {
        $options = &BuscarProds($RowProd['Modelo'],$RCab['Consignatario']);
        $c++;
        $trProd .= '<tr>
                    <td class="col-xs-1">
                        <input value="'.$c.'-'.$c2.'-'.$RCab['Consignatario'].'" type="text" class="form-control" readonly="readonly">
                    </td>
                    <td class="col-xs-2">
                        <select class="form-control">'.$Mercancia.'</select>                        
                    </td>
                    <td class="col-xs-2">
                        <input value="'.$RowProd["Descripcion"].'" type="text" name="Descripcion[]" class="form-control" readonly="readonly">
                    </td>
                    <td class="col-xs-1">
                        <input value="'.$RowProd["Cantidad"].'" id="cantidad" name="Cantidad[]" type="text" class="form-control">
                    </td>
                    <td class="col-xs-1">
                        <input value="'.$RowProd["Costo"].'" id="costo" name="Costo[]" type="text" class="form-control">
                    </td>
                    <td class="col-xs-1">
                        <input value="'.$RowProd["Total"].'" id="total" name="Total[]" type="text" class="form-control" readonly="readonly">
                    </td>   
                </tr>';

    }
function &BuscarProds($code, $store)
    {
        static $Mercancia = '';
        $Tienda = CargarTienda($store); 
        $CSQPR = consultar2("SELECT CodProd, Descrip FROM SAPROD ORDER BY CodProd",0,$Tienda);
        while($rowT = mssql_fetch_array($CSQPR)){
            if($rowT['CodProd']==$code){
                $Mercancia .= '<option value="'.$code.'" selected>'.$code.'</option>';
            }else{
                $Mercancia .= '<option value="'.$rowT['CodProd'].'">'.$rowT['CodProd'].'</option>';    
            }
        }
        return $Mercancia;
    } 

The question is, I have 47 Products ... but in the while it only shows me the first record, it does not keep showing the others ... Any ideas?

    
asked by Maykol Rivas 30.09.2016 в 22:33
source

1 answer

0

then you can check if $RProd really brings the 47 products, making a count or similar. Most likely, an error in SearchProds or LoadStore is stopping the script. There you need to activate php errors, or use a debugger.

Added: the function mssql_fech_array is discontinued in PHP 7. I recommend using PDO and see if you still have the same problem. Also add error detection, at the beginning of the script add:

error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', '1');
    
answered by 30.09.2016 в 23:15