HighDots Forums  

(php) Repeat Region + Substr

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss (php) Repeat Region + Substr in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Leandro_Brazil
 
Posts: n/a

Default (php) Repeat Region + Substr - 11-20-2004 , 09:23 AM






Hi for everybody!!!

I?m doing a portal of news and I created a system with php and MySql to solve
it.

I have a table where a put my news it?s call (noticias)

So in a page I created a Recordset the take these news in the table and
display it in a page.

I created a function (substr), and with it a take the 100 firts letter of my
noticia_text and display like a description of the news.

Here is the code:

<?php
$txt = $row_rsNoticias['noticia_texto'];
$rest = substr("$tx", 0, 100);
?>

And I put other code to display the relatin of the news.

<?php do { ?>
<br />
<h3 class="ultimas"><?php echo $row_rsNoticias['noticia_titulo']; ?></h3>
<p class="margin"><?php echo $rest; ?>...</p>
<a href="noticia_ler.php?noticia_id=<?php echo $row_rsNoticias["noticia_id"];
?>" class="leia">Leia mais</a>
<hr />
<?php } while ($row_rsNoticias = mysql_fetch_assoc($rsNoticias)); ?>

Good, these codition function perfect but I find I problem and I?m not find a
solution for it.

The problem is:

For every news the description is IGUAL.

It isn?t being relative with the each news.

And the function (substr) that I created need to tike the 100 first lettter
respectiv of each news.

Help-me width please!

I don?t more what to do to solve it

Thanks


Reply With Quote
  #2  
Old   
Mark
 
Posts: n/a

Default Re: (php) Repeat Region + Substr - 11-20-2004 , 12:09 PM






You're stepping through your records between the

<?php do { ?>

and the

<?php } while ($row_rsNoticias = mysql_fetch_assoc($rsNoticias)); ?>



Your code

<?php
$txt = $row_rsNoticias['noticia_texto'];
$rest = substr("$tx", 0, 100);
?>

is before this stepping through so you're always going to show the data from
the first record. You need to move your code to work out the first 100 chrs
to be part of your stepping code, like

<?php do { ?>

<?php
$txt = $row_rsNoticias['noticia_texto'];
$rest = substr("$tx", 0, 100);
?>

<br />
<h3 class="ultimas"><?php echo $row_rsNoticias['noticia_titulo']; ?></h3>
<p class="margin"><?php echo $rest; ?>...</p>
<a href="noticia_ler.php?noticia_id=<?php echo
$row_rsNoticias["noticia_id"]; ?>" class="leia">Leia mais</a>
<hr />
<?php } while ($row_rsNoticias = mysql_fetch_assoc($rsNoticias)); ?>







"Leandro_Brazil" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
Hi for everybody!!!

I?m doing a portal of news and I created a system with php and MySql to
solve
it.

I have a table where a put my news it?s call (noticias)

So in a page I created a Recordset the take these news in the table and
display it in a page.

I created a function (substr), and with it a take the 100 firts letter of
my
noticia_text and display like a description of the news.

Here is the code:

?php
$txt = $row_rsNoticias['noticia_texto'];
$rest = substr("$tx", 0, 100);
?

And I put other code to display the relatin of the news.

?php do { ?
br /
h3 class="ultimas"><?php echo $row_rsNoticias['noticia_titulo']; ?></h3
p class="margin"><?php echo $rest; ?>...</p
a href="noticia_ler.php?noticia_id=<?php echo
$row_rsNoticias["noticia_id"];
?>" class="leia">Leia mais</a
hr /
?php } while ($row_rsNoticias = mysql_fetch_assoc($rsNoticias)); ?

Good, these codition function perfect but I find I problem and I?m not
find a
solution for it.

The problem is:

For every news the description is IGUAL.

It isn?t being relative with the each news.

And the function (substr) that I created need to tike the 100 first
lettter
respectiv of each news.

Help-me width please!

I don?t more what to do to solve it

Thanks




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.