SirPereira Posted April 3, 2010 Share Posted April 3, 2010 Hey guys, I'm converting my CSS simple template, to a dynamic one. Right now, I've this in CSS: CSS: <div class="fl_left"> <h2><a href="#">CINEMA // 6 de Abril »</a></h2> <img src="images/agenda/1.png" alt="" /> <p><strong><a href="#">O Laço Branco (Das weisse Band)</a></strong></p> <p><span times="" new="">Pax Julia - Teatro Municipal - 21h30<br /> M16 | 3,00€</span><span times="" new=""><strong><br /> </strong>De Michael Haneke, com Ulrich Tukur, Susanne Lothar, Josef Bierbichler</span></p> <p><span times="" new="">Uma aldeia protestante da Alemanha do Norte. 1913/1914. Em vésperas da primeira guerra mundial. Uma história de crianças e adolescentes pertencentes a um coro liderado pelo professor da aldeia, e suas famílias: o Barão, o gerente, o pastor, o médico, a parteira, camponeses. Acidentes estranhos acontecem e, gradualmente, assumem o carácter de uma punição ritual. Quem está por de trás de tudo isso?</span></p> </div> <div class="fl_right"> <h2><a href="#">lanÇAMENTO DO LIVRO // 8 de abril»</a></h2> <img src="images/agenda/2.png" alt="" /> <p><strong><a href="#">Até Amanhã - em Laetoli no Alentejo numa Lua</a></strong></p> <p>Auditório da Biblioteca Municipal de Beja - 21h30<br /> De António Murteira </p> <div></div> <em>Os fragmentos que constituem o corpo narrativo de Até Amanhã, de António Murteira, são (...) epígrafes memorialísticas que se pretendem inscritas numa determinada realidade, transcendendo-a para se assumirem como incisivas denúncias de um tempo e das suas alegorias, dos seus imaginários, dos seus percursos, apontamentos críticos de uma realidade que se construiu a mãos ambas, sobre linimentos de um tempo de êxtases, de paixões, de entregas: um tempo sobre o qual o autor reflecte e dele assume os medos, os assombros, a entrega. (…) Há nesta escrita, atravessada por uma poética de grande qualidade metafórica, de íntimos rumores, uma fala orgânica que se vai adensando na medida em que esse exercício evolui e uniformiza. O autor como que busca um interlocutor, um cúmplice para que o diálogo que estes textos procuram, se estabeleça.</em> <div></div> <div></div> </div> <br class="clear" /> <div class="fl_left"> <h2><a href="#">MÚSICA // 8 DE ABRIL »</a></h2> <img src="images/agenda/3.png" alt="" /> <p><strong><a href="#">Cristina Nóbrega - Palavras do Meu Fado</a></strong></p> <p>Pax Julia - Teatro Municipal - 22h00<br /> M6 | 8,00€<strong><br /> </strong>Org.: Grupo Cameirinha </p> <div></div> <p>As receitas do espectáculo reverterão a favor da Buganvilia, instituição de apoio a crianças e jovens sediada na capital do Baixo Alentejo.</p> </div> <div class="fl_right"> <h2><a href="#">OPERETA // 10 DE ABRIL »</a></h2> <img src="images/agenda/4.png" alt="" /> <p><strong><a href="#">Campinos, Mulheres e Fado<br /> </a></strong><br /> Pela Companhia de Teatro do Ribatejo <br /> Co-Financiamento - INALENTEJO, QREN e UE<br /> <br /> A Companhia de Teatro do Ribatejo apresenta a opereta “Campinos, Mulheres e Fado”. Cerca de duas dezenas de actores cantam, dançam e representam envolvidos numa cenografia de grande beleza. Esta opereta é uma viagem ao espírito ribatejano em ritmo de fado e fandango com belas canções a envolverem o público. Encenação de João Coutinho. </p> </div> <br class="clear" /> </div> Well, what I want? I've a database with this fields: - id_evento - the primary key, the id - thumb_evento - url of thumbnail - tit_evento - title of event - desc_evento - description of the event (the news body) - cat_evento - the category, that text that appears before the date (6 de abril, etc.) - data_evento - the date of the event written in text As they're subdivided into two div's (for the left, and for the right) I would like to know how to change the code so it fits good as the last 4 ids are available. Actually I've been trying to make this: <?php $par = 0; $sql = "SELECT * FROM tv_eventos ORDER BY id_evento DESC LIMIT 4"; if ($sql) { for ($pass = 0; $pass < mysql_num_rows($sql); $pass++){ while ($row = mysql_fetch_assoc($sql)) { $par++; if ($par % 2 == 0) { echo "<div class='fl_left'>"; echo "<h2><a href='#'>".$row['cat_evento']." // ".$row['data_evento']." »</a></h2>"; echo "<img src='images/agenda/1.png' />"; echo "<p><strong><a href='#'>".$row['tit_evento']."</a></strong></p>"; echo "<p><span times='' new=''>".$row['desc_evento']."</span></p>"; echo "</div>"; } } } } ?> (and yes, it does connect to database, I have the include for it in the main of page) But no success, it showed an error: Warning: mysql_num_rows() expects parameter 1 to be resource, string given in \v2\index.php on line 113 that I couldn't understood what was the wrong side of the code... Any suggestions? Link to comment https://forums.phpfreaks.com/topic/197439-news-template/ Share on other sites More sharing options...
trq Posted April 3, 2010 Share Posted April 3, 2010 You haven't actually executed your query. See mysql_query. And please, we don't need a life story, relevant code is sufficient. Link to comment https://forums.phpfreaks.com/topic/197439-news-template/#findComment-1036285 Share on other sites More sharing options...
SirPereira Posted April 3, 2010 Author Share Posted April 3, 2010 Woow... it has easier than I thought, I got all the coding made in 3 minutes. Sorry about the misunderstanding with the mysql_query, just forgot to execute it. And sorry about the mess, but some people say that users don't give the essential details, maybe I exaggerated, sorry about that. Hum, just another question with fast reply, maybe this a little more SQL, but, Imagine that I already have a table created, and I want to add a field, how I give to the already existing values in that table, the value of the new field, even it is a default one? Regards, and sorry for anything Link to comment https://forums.phpfreaks.com/topic/197439-news-template/#findComment-1036287 Share on other sites More sharing options...
SirPereira Posted April 3, 2010 Author Share Posted April 3, 2010 Hm, don't know why, but can't edit my previous post. But I've solved it. But now, I've another problem. I've created an order field in table, ordem_evento, so I can manipulate easier how I want it to be seen on the page. But now, it shows 3 events in one side, and just one on another with this code: <?php $par = 0; $sql = mysql_query("SELECT * FROM tv_eventos ORDER BY ordem_evento DESC LIMIT 4"); if ($sql) { for ($pass = 0; $pass < mysql_num_rows($sql); $pass++){ while ($row = mysql_fetch_assoc($sql)) { $par++; if ($par % 2 == 0) { echo "<div class='fl_left'>"; echo "<h2><a href='#'>".$row['cat_evento']." // ".$row['data_evento']." »</a></h2>"; echo "<img src='images/agenda/".$row['thumb_evento']."' />"; echo "<p><strong><a href='#'>".$row['tit_evento']."</a></strong></p>"; echo "<p><span times='' new=''>".$row['desc_evento']."</span></p>"; echo "</div>"; } else { echo "<div class='fl_right'>"; echo "<h2><a href='#'>".$row['cat_evento']." // ".$row['data_evento']." »</a></h2>"; echo "<img src='images/agenda/".$row['thumb_evento']."' />"; echo "<p><strong><a href='#'>".$row['tit_evento']."</a></strong></p>"; echo "<p><span times='' new=''>".$row['desc_evento']."</span></p>"; echo "</div>"; } } } } ?> Each event has it's own order (1,2,3,4 - respectively). Isn't it supposed to shown 2 per column? Forget this. I'm almost sleeping. I just forgot to 'kill' the DESC from the query. Everything solved, thank you Link to comment https://forums.phpfreaks.com/topic/197439-news-template/#findComment-1036288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.