Jump to content

Recommended Posts

Currently I have row results showing like:

 

word1

word2

word3

word4

 

How do I get them to display straight and seperate them with a comma like:

 

word1, word2, word3, word4

 

Here is my current code:

 

$query = "SELECT keyword FROM keywords ORDER BY RAND() LIMIT 1,2000";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){

    echo "$row['keyword']";    
} 

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/241378-need-help-with-mysql-row-results/
Share on other sites

How are they entered into the database? Does each keyword have its own row? Are there multiple keywords on a single row separated by line breaks?

 

A dump of your SQL table would help

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$arr = explode( PHP_EOL, $row['keyword'] );
echo implode( ', ', $arr );
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.