Total result php mysql

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
PHP Mysql
limit the result to 5
I can display the 5 results using a do & while which it ok.

I want to list the total or all the results without using a do or while

this is so I can combine the results and remove duplicate words from the
total results

Do & While
row    result
1        this is the top
2        this is the bottom
3        this is the middle
4        this is the end
5        this is the finish

This is what I want to do:
this is the top this is the bottom this is the middle this is the end this
is the finish

modified result::
this is the top bottom middle end finish

can this be done


Re: Total result php mysql


i'm not sure what really your problem.
You need a for or while to walk thru your result set.

Your result could be produced like this for example:

$first = true;
while($row = mysql_fetch_row($result)){
     $string = $row[0];
     $first = false;
  } else {
     $string .= strstr($row[0], 'this is the');

echo $string;

This is not been tested, and it is only one way to get the result, my
be there also better way's, but for prompt scripting thats my solution.


Re: Total result php mysql


error in the system, wouldn't work.


$string .= str_replace($row[0], 'this is the ', ' ');

blame on me for the first suggestion. ;-)

Re: Total result php mysql

Great but not what I required.

You cannot put a 'while' command into a string to make it one item from say
SQL on the other hand will only display the record once so you only have to
repeat the command 5 times then combile the lot.

$word1 = mysql_fetch_assoc($rsproductkey);
$word2 = mysql_fetch_assoc($rsproductkey);
$word3 = mysql_fetch_assoc($rsproductkey);
$word4 = mysql_fetch_assoc($rsproductkey);
$word5 = mysql_fetch_assoc($rsproductkey);
$wr = ($word1['Product_name']." ".$word2['Product_name']."
".$word3['Product_name']." ".$word4['Product_name']."

then you can do a remove duplicate words from the $wr using something like
a array_flip() .

Took me time but it work.

Regards Nik

Quoted text here. Click to load it

Site Timeline