Try this.

<?
$substring = "SELECT SUBSTRING_INDEX(field, '<p>', 5) FROM table WHERE
start_date <= CURRENT_DATE ORDER BY start_date DESC;";

    $response = mysql_query( $substring, $dbh );

while ( $data = mysql_fetch_array( $response ) ) {
    print $data['field_name']."\n";
}
?>


I'm not sure if it does what you want it to, but your original code wouldn't do
anything no matter how you spun it, so this is my best guess.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


----- Original Message -----
From: "Steve Marquez" <[EMAIL PROTECTED]>
To: "Becoming Digital" <[EMAIL PROTECTED]>; "MySQL List"
<[EMAIL PROTECTED]>
Sent: Friday, 30 May, 2003 09:59
Subject: Re: Limiting words...


Edward,

Thanks, this worked with the field, however it only works in the shell. I am
trying to make it work in a PHP page.

Here is my code, am I doing something wrong?

<?php

$substring = "SELECT SUBSTRING_INDEX(field, '<p>', 5) FROM table WHERE
start_date <= CURRENT_DATE ORDER BY start_date DESC;";

    $response = mysql_query( $substring, $dbh );

if ( $one_line_of_data = mysql_fetch_array( $response ) ) {
    extract ( $one_line_of_data );
} echo "$field\n";

?>

Thanks,

-Steve Marquez
[EMAIL PROTECTED]


> SELECT SUBSTRING_INDEX(field, ' ', 25) FROM tablename
>
> Edward Dudlik
> Becoming Digital
> www.becomingdigital.com
>
>
> ----- Original Message -----
> From: "Adam Clauss" <[EMAIL PROTECTED]>
> To: "'Steve Marquez'" <[EMAIL PROTECTED]>; "'MySQL List'"
> <[EMAIL PROTECTED]>
> Sent: Wednesday, 28 May, 2003 22:07
> Subject: RE: Limiting words...
>
>
> Maybe this:
> SUBSTRING_INDEX(str,delim,count)
> Returns the substring from string str before count occurrences of the
> delimiter delim. If count is positive, everything to the left of the final
> delimiter (counting from the left) is returned. If count is negative,
> everything to the right of the final delimiter (counting from the right) is
> returned:
> mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
>       -> 'www.mysql'
>
> Except do with sapces instead of period?
>
> Adam Clauss
> [EMAIL PROTECTED]
>
>
>> -----Original Message-----
>> From: Steve Marquez [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, May 28, 2003 8:49 PM
>> To: MySQL List
>> Subject: Limiting words...
>>
>>
>> Hi all,
>>
>> I have articles that I wish to display on a site. They are
>> contained in long
>> text fields in a MySQL table.
>>
>> I would like to display the first 25 words in the article, then have a
>> "continued" link to the rest of the article on another page.
>>
>> I am using PHP on my pages currently.
>>
>> Anyone know how to accomplish this?
>>
>> Thanks for your help.
>>
>> -Steve Marquez
>> Marquez Design
>>
> www.marquez-design.com
> [EMAIL PROTECTED]
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>
>
>


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to