简体   繁体   中英

HTML table generated with PHP

function destinations(){
    global $db;

    $numri1 = $db->query("SELECT * FROM destinations WHERE direction='1';");

        $i = 1;
        while ($row = mysql_fetch_array($numri1)) {
            if ($i % 2 != "0") # An odd row
              $rowColor = "bgC1";
            else # An even row
              $rowColor = "bgC2";

            $direction1 .= '<tr class="'.$rowColor.'">
                                <td>'.$i.'</td>
                                <td>'.$row['name'].'</td>
                            </tr>';
        $i++;
        }


$table1 =  '<table width="30%" style="margin:10px 10px 0 10px;" class="extra" cellspacing="1" cellpadding="5" border="0" >
            <tr class="bgC3" style="font-weight:bold;>
                <td>asd</td>
                <td>Qytetet domestike</td>
            </tr>
            '.$direction1.'
            </table>';

        return $table1;
}

There must be a small problem with this because when its displayed in browser it doest show this:

        <tr class="bgC3" style="font-weight:bold;>
            <td>asd</td>
            <td>Qytetet domestike</td>
        </tr>

well, it shows it but it replaces the values the "asd" and "Qytetet domestike"!

You're missing a quote at the end of your style attribute.

Change:

<tr class="bgC3" style="font-weight:bold;>

To:

<tr class="bgC3" style="font-weight:bold;">
                                         ^

See this fiddle ? No table displayed! Now have a look at this fiddle .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM