Pobieranie kolumny z mysql i zapisanie każdej wartości w odrębnej zmiennej

Odpowiedz Nowy wątek
2015-02-24 08:50
0

Witam wszystkich forumowiczów.

Mój kod PHP wygląda następująco:

<?php

   include 'connect.php';

if($formula == ''){
$query  = "SELECT * FROM products WHERE ink = '$ink' AND width = $width AND length = $length";
    if($ink == '') {
        $query  = "SELECT * FROM products WHERE width = $width AND length = $length";
        if($width == 0){
        $query  = "SELECT * FROM products WHERE length = $length";
    }
    }
    if($width == 0){
    $query  = "SELECT * FROM products WHERE ink = '$ink' AND length = $length";
    }
    if($length == 0){
    $query  = "SELECT * FROM products WHERE ink = '$ink' AND width = $width";
    }
}

elseif($ink == ''){
$query  = "SELECT * FROM products WHERE formula = '$formula' AND width = $width AND length = $length";
    if($formula == ''){
    $query  = "SELECT * FROM products WHERE width = $width AND length = $length";
    }
    if($width == 0){
    $query  = "SELECT * FROM products WHERE formula = '$formula' AND length = $length";
    }
    if($length == 0){
    $query  = "SELECT * FROM products WHERE formula = '$formula' AND width = $width";
    }
}

elseif($width == 0){
$query  = "SELECT * FROM products WHERE formula = '$formula' AND ink = '$ink' AND length = $length";
    if($length == 0){
    $query  = "SELECT * FROM products WHERE formula = '$formula' AND ink = '$ink'";
}
}

elseif($length == 0){
$query  = "SELECT * FROM products WHERE formula = '$formula' AND ink = '$ink' AND width = $width";
}

else{
$query  = "SELECT * FROM products WHERE formula = '$formula' AND ink = '$ink' AND width = $width AND length = $length";
}

$result = mysql_query($query) or die ("0");
if (!mysql_num_rows($result)) die("0");

$i = 0;

while($row = mysql_fetch_array($result))
{
    echo "{$row['symbol']} ";
}

?>  

Otrzymuję taki wynik:
B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B121 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B128 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120 B120R B120R B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 B112 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110 P110W P110W P110W P110W P110W

Potrzebuję zaimportować każdą powyższą wartość jako osobna zmienną w C# (najlepiej w tabeli (array)), abym mógł łatwo się do każdej z wartości odwołać:
np.
symbols[0],
symbols[1],

Bardzo proszę o pomoc. Pozdrawiam.

edytowany 1x, ostatnio: Detro, 2015-02-24 08:51

Pozostało 580 znaków

2015-02-24 09:02
1

Mozesz np jakos tak:

string phpResult = pobierzWynikZTegoTwojegoPehapa().Trim();
string[] symbols= phpResult.Split(' ');

Pozostało 580 znaków

Odpowiedz
Liczba odpowiedzi na stronę

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0