Jump to content
php.lv forumi

Mysql ierakstu parādīšana tabulas veidā


vitao.web

Recommended Posts

Labdien!

 

Jautājums, vai ir iespējams bez javascript un citiem palīgi izdarīt tā ka parādot no datu bāzes ierakstus tabulas veidā piemēram pirmā rinda ir sarkana , bet otrā zaļa un tad atkal 3 rinda sarkana?

 

Skatījos tabulu paraugus googlē, bet tur tik dod tos <table> piemērus, kas man nepatīk pārāk.

 

Paldies!

Link to comment
Share on other sites

$i = 0;
$klase = $i++%2==1 ? 'red' : 'green';

// Parādu ar
<div class='".$klase."'>

 

Problēma ir tāda ka visi ieraksti ir zali :( Kur kluda? jo pec idejas visiem nevienadajiem cipariem vajadzetu but zaliem.

 

 

Vai varat paskaidrot, ko es nepareizi esmu izdarījis?

Edited by vitao.web
Link to comment
Share on other sites

dbConnect();
$i = 0;
$klase = $i++%2==1 ? 'even' : 'odd';
$izs = dbFetch("select *
                   from blog
                   order by id
                   DESC
                   LIMIT
                   8");
   while($rez = mysql_fetch_assoc($izs)){
       echo "
            <div class='".$klase."'>
              <div class='table_title'>".$rez['title']."</div>
               <div class='table_date'>".$rez['date']."</div>
               <div class='table_message'>".$rez['message']."</div>
               <div class='clear'></div><br />
          </div>";
   }
dbDisconect();?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...