Autor Zpráva
gepir
Profil
Cus, mam takovy dotaz, potreboval bych pomoct s ikonou v databazi. Je to asi takto, mam ve vypisu dve hodnoty "1" a "0" ty jsou pod promenou $status potrebuju udelat to, kdyz se bude rovnat $status "1" tak se zobrazi ikona s krizkem a kdyz se bude rovnat "0" tak ikona s fajfkou. Zkousel jsem to takto -

<?php
    while($row = odbc_fetch_array($result, ODBC_FETCH_ASSOC)) {
?> 
<?php
        $owner = odbc_result($result, 1);
        $Hostname = odbc_result($result, 2);
        $ComputerModel = odbc_result($result, 3);
        $ComputerSerial = odbc_result($result, 4);
        $Type = odbc_result($result, 5);
        $Status = odbc_result($result, 6);
?>
<?
if($Status == '0') {  
     $image="icon-system-status-na.gif";
    $im=imagecreatefromgif($image);  
      
    imagegif($im);  
    destroy($im);  
?>
<?
if($Status == '1') {  
     $image="icon-system-status-ok.gif";  
     $im=imagecreatefromgif($image);  
      
     imagegif($im);  
     destroy($im);  
?>
<?
print ( "$image");
?>
<tr class="gray">
<?php
	print ( "<td class=\"date\">$owner</td>");
        print ( "<td class=\"date\">$Hostname</td>");
	print ( "<td class=\"date\">$ComputerModel</td>");
        print ( "<td class=\"date\">$ComputerSeria</td>");
        print ( "<td class=\"date\">$Type</td>");
        print ( "<td class=\"date\">$Status</td>");
?>  


ale toto nejde a nevim proc, misto ikony se porad zobrazuje "1" nebo "0". Pomuze nekdo?

Diky

Moderátor Alphard: Vkládej prosím kód mezi značky [pre] a [/pre] (stačí kliknout na ).
Alphard
Profil
gepir:
Nechápu polovinu vašeho kódu...

<?php
    while($row = odbc_fetch_array($result, ODBC_FETCH_ASSOC)) {
?> 
<?php
        $owner = odbc_result($result, 1);
        $Hostname = odbc_result($result, 2);
        $ComputerModel = odbc_result($result, 3);
        $ComputerSerial = odbc_result($result, 4);
        $Type = odbc_result($result, 5);
        $Status = odbc_result($result, 6);
?>
<?
    $image = array (0 => "icon-system-status-na.gif", 1 => "icon-system-status-ok.gif");
?>
<tr class="gray">
<?php
    print ( "<td class=\"date\">$owner</td>");
        print ( "<td class=\"date\">$Hostname</td>");
    print ( "<td class=\"date\">$ComputerModel</td>");
        print ( "<td class=\"date\">$ComputerSeria</td>");
        print ( "<td class=\"date\">$Type</td>");
        print ( "<td class=\"date\"><img src=\"$image[$Status]\"></td>");
?>  
gepir
Profil
Ja vim je to docela zmatene ale je to delane moc na rychlo, funguje to diky moc
gepir
Profil
mam jeste jednu otazku, jak presne udelat obarveni radku ve vypisu, mam v databazi definovane barvy ale nechce mi to obarvovat, kdyz jsem vynechal css tak to nic neudelalo a rozhodilo mi to celou tabulku, problem vsak je ze se data berou ze dvou tabulek. Kdyz to udelam normalne tak mi to vypise do slouce jen nazev barvy ale neobarvi mi to ani tu danou bunku.
tady je kod ve kterem se to zpracovat -
 <?php
$t_Form = array_merge($_GET, $_POST);

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"; 
}
$db = odbc_connect("TLMA","tlm_server","Tlm50Tmp");
$m_Sql = "SELECT DISTINCT
    eamt.emp_lotus_notes,
    agent.hostname,
    vendor.name,
    prod.name,
    prod.version,
    swc.level_,
    swc.comment,
    swc.color
FROM
    adm.agent agent,
    adm.node node,
    brn.hw_connection hwc,
    brn.eamt_owner eamt,
    brn.sw_connection swc,
    swcat.swproduct prod,
    swcat.vendor vendor,
    adm.agent_inv agent_inv,
    adm.prod_inv prod_inv
WHERE
    vendor.id = prod.vendor_id AND
    agent.id = agent_inv.agent_id AND
    agent_inv.component_id = swc.level_4_id AND
    swc.level_3_id = prod.id AND
    agent.node_id = node.id AND
    node.id = hwc.node_id AND
    hwc.eamt_id = eamt.id AND
    swc.level_3_id = prod_inv.product_id AND
    prod_inv.end_time = '9999-12-31 00:00:00' AND
    agent.hostname $t_SqlHost AND
    eamt.emp_dpt $t_SqlDpt
ORDER BY
    swc.level_ DESC,
    eamt.emp_lotus_notes,
    agent.hostname,
    prod.name,
    prod.version";
        
$result = odbc_exec($db, $m_Sql);
?>
<div class="basic-table">
    <table class="basic-table" cellspacing="1" cellpadding="0" width="100%">
        <caption>Hardware </caption>
<tr class="green-med-dark">
<th style="white-space:nowrap">Registered owner</th>
<th style="white-space:nowrap">Hostname</th>
<th style="white-space:nowrap">SW Manufacturer</th>
<th style="white-space:nowrap">SW Name</th>
<th style="white-space:nowrap">SW Version</th>
<th style="white-space:nowrap">SW Type</th>
<th style="white-space:nowrap">SW Comment</th>

</tr>

<?php
    while($row = odbc_fetch_array($result, ODBC_FETCH_ASSOC)) {
?> 
<tr class="gray">
<?php
foreach ( $row as $index )
	print ( "<td class=\"date\">$index</td>")
?>
</tr>
      
    <?php        
    }

    odbc_free_result($result);
    odbc_close($db);
    ?>

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: