1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I need help, problem file

Discussion in 'PHP' started by georgege, Mar 11, 2009.

  1. #1
    I have a PHP file that I extract data from the database, the data I want to defend as a table, but the problem is that I only appear in the line. If someone can tell me where I wrong?

    <html>
    <body>
    <tabel>
    <?
    $link = mysql_connect($server, $user, $password) or die("Nu se poate conecta");
    mysql_select_db($database, $link) or die("nu se poate alege baza de date");

    $query = "select * from fotbal where country like '%".mysql_real_escape_string($tara)."%' and state < 3";

    $result = mysql_query($query) or die("Query failed");

    $rezult = array();
    while ($myrow = mysql_fetch_array($result))
    {
    echo "\n<tr>";
    echo "\n<td>".$myrow["competition"].":</td>";
    echo "\n<td>".$myrow["club1"]."<b>&nbsp;&nbsp;".$myrow["score1"]."-".$myrow["score2"]."</b>&nbsp;&nbsp;".$myrow["club2"]."</td>";
    echo "\n<td>".$myrow["info1"]." ".$myrow["info2"]."</td>";
    echo "\n</tr>";
    }

    mysql_close($link);

    ?>

    </tabel>
    </body>
    </html>


    Thank you in advance.

    Would be one thing: how to color these rows?

    Best regards,
    george
     
    georgege, Mar 11, 2009 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    on line 3 "<tabel>" ~> wrong spelling
     
    bartolay13, Mar 11, 2009 IP
  3. georgege

    georgege Greenhorn

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #3
    Hi bartolay13,

    Thanks very much, now is work.
    I am very tired and I saw no mistake.

    Thanks again,
    george
     
    georgege, Mar 12, 2009 IP
  4. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #4
    A few tips/solutions :
    1. table not tabel
    2. \n - remove them all
    3. $var["value"] - replace double-quotes with single-quotes
     
    ActiveFrost, Mar 12, 2009 IP
  5. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Shouldn't have any impact on anything, and they make it easier to debug the HTML code.
    Microscopically faster to evaluate but shouldn't have any real impact.
     
    SmallPotatoes, Mar 12, 2009 IP
  6. santaro

    santaro Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
    if ($i++ % 2 == 1) $color="#f0f0f0"; else $color="#0f0f0f";
    echo "\n<td bgcolor=\"$color\">".$myrow["competition"].":</td>";
    echo "\n<td>".$myrow["club1"]."<b>&nbsp;&nbsp;".$myrow["score1"]."-".$myrow["score2"]."</b>&nbsp;&nbsp;".$myrow["club2"]."</td>";
    echo "\n<td>".$myrow["info1"]." ".$myrow["info2"]."</td>";
    
    Code (markup):
     
    santaro, Mar 12, 2009 IP