Autor Zpráva
gepir
Profil
mam tady dalsi otazku, mam dva dotazy do databaze oba mi vyjedou ale z prvniho selectu mi to nepropise do vysledne tabulky sprava data. Problem spociva v tom ze z prvni databaze taham informace o tom jaky je LEVEL usera je to 1,2 nebo 3 kdyz jsem zkusil samotny dotaz tak mi to vypise bez problemu vytvorim si promennou ktera nese ona data ale error vznikne v tom kdyz chci aby se ty data propsaly do tabulky. Vypisuje to jen nuly nic jineho. Kde mam error?

<?php
$t_Form = array_merge($_GET, $_POST);
$db = odbc_connect("") or die ("Could not connect to DB2");

$m_Sql = "SELECT DISTINCT
    file_name,
    level_,
    comment,
    color
FROM
    brn.sw_connection";
    
$Result = odbc_exec($db, $m_Sql);
while($row = odbc_fetch_array($Result, ODBC_FETCH_ASSOC)) {?>
  <?php
    $image = array (0 => "icon-system-status-alert.gif",
                    1 => "icon-system-status-ok.gif",
                    2 => "icon-system-status-ok.gif",
                    21 => "icon-system-status-ok.gif",
                    41 => "icon-system-status-ok.gif",
                    61 => "icon-system-status-na.gif",
                    62 => "icon-system-status-na.gif",
                    81 => "icon-system-status-na.gif");
?>
  <?php        
    }
        $Level = odbc_result($Result,2);
        $Comment = odbc_result($Result,3);
    ?>       
<?php
$t_Form = array_merge($_GET, $_POST);
$db = odbc_connect("") or die("Could not connect to DB2!");

if ( $t_Form['dept'] and $t_Form['dept'] != "" ) { 
$t_SqlDpt = "= '$t_Form[dept]'"; 
} else { 
$t_SqlDpt = "IS NOT NULL"; 
} 
if ( $t_Form['hostname'] and $t_Form['hostname'] != "" ) { 
$t_SqlHost = "= '$t_Form[hostname]'"; 
} else { 
$t_SqlHost = "IS NOT NULL"; 
}

$t_Sql = "WITH known
AS ( SELECT DISTINCT
    b.id,
    b.name
FROM
    rtm.signature a,
    rtm.unknown b
WHERE
    a.name = b.name )
SELECT DISTINCT
    a.text1,
    a.description,
    a.name,
    a.size_,
    a.version,
    a.path
FROM
    known c RIGHT OUTER JOIN
    rtm.unknown a ON
        c.id = a.id LEFT OUTER JOIN 
    rtm.signature b ON
        ( a.name = b.name AND
        a.size_ = b.file_size ),
    rtm.agent_unk_rel d,
    rtm.agent e
WHERE
    b.file_size IS NULL AND
    a.name IS NOT NULL AND
    a.id = d.unknown_id AND
    d.agent_id = e.id AND
    e.hostname $t_SqlHost
ORDER BY
    a.text1,
    a.description,
    a.name";
        
$result = odbc_exec($db, $t_Sql);
?>
<div class="basic-table">
    <table class="basic-table" cellspacing="1" cellpadding="0" width="100%">
        <caption>Computers assigned to the department - <?php print $t_Form['dept']; ?> </caption>
<tr class="green-med-dark">
<th style="white-space:normal">Possible SW name</th>
<th style="white-space:normal">Possible component</th>
<th style="white-space:normal">File name</th>
<th style="white-space:normal">File size</th>
<th style="white-space:normal">Version</th>
<th style="white-space:normal">Path</th>
<th style="white-space:normal">Level</th>
<th style="white-space:normal">Comment</th>
</tr>

<?php
    while($row = odbc_fetch_array($result, ODBC_FETCH_ASSOC)) {
?> 
<?php
        $possibleSW = odbc_result($result, 1);
        $possibleCO = odbc_result($result, 2);
        $FileName = odbc_result($result, 3);
        $FileSize = odbc_result($result, 4);
        $Version = odbc_result($result, 5);
        $Path = odbc_result($result, 6);
        
?>

<tr class="gray">
<?php
	print ( "<td class=\"date\">$possibleSW</td>");
        print ( "<td class=\"date\">$possibleCO</td>");
	print ( "<td class=\"date\">$FileName</td>");
        print ( "<td class=\"date\">$FileSize</td>");
        print ( "<td class=\"date\">$Version</td>");
        print ( "<td class=\"date\">$Path</td>");
        print ( "<td class=\"data\"><img src=\"$image[$Level]\"</td>");
        print ( "<td class=\"data\">$Comment</td>"); 
?>
</tr>
      
    <?php        
    }

    odbc_free_result($result);
    odbc_close($db);
    ?>
Kajman_
Profil *
Asi si v prvním cyklu chcete ukládat jednotlivé řádky do pole, ale neděláte tak. Nechápu k čemu tam tedy máte while.

A být vaším zaměstnavatelem, tak už podruhé letíte za to, že zveřejňujete hesla k databázím :-)
gepir
Profil
no, nejak jsem zapomel ty hesla odstanit, ale stejne to neni nikde na netu jen v interni siti takze to zas takovy error neni :-)

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: