Jump to content

[SOLVED] Too Many |


ipwnzphp

Recommended Posts

Hello, I would like to know how to remove the ending | of my mysql results. My code is below

 

$result = mysql_query("SELECT * FROM `CATS` WHERE PING = '1'") or die(mysql_error());
while ($row = mysql_fetch_array($result)) { 
$ping = $row[PING_NAME];
echo "$ping | ";
}

 

???

Link to comment
Share on other sites

Thanks now i got another issue.

 

$result = mysql_query("SELECT * FROM `CATS` WHERE PING = '1'") or die(mysql_error());
    $count=0;
    $PING = Array();
    while ($row = mysql_fetch_array($result)) { 
    $PING[] = $row[cat_name];
    }
    
    if($count == "3") {
$count = 0;
    echo "<br>";
    }
        echo implode(' | ', $PING);
    $count++;

 

its spoused to echo 3 out and then br than 3 more and its not now.  ???

Link to comment
Share on other sites

<?php
  $result = mysql_query("SELECT * FROM `CATS` WHERE PING = '1'")
    or die(mysql_error());
  $count=0;
  $PING = Array();
  while ($row = mysql_fetch_array($result)) { 
    $PING[] = $row[cat_name];
    if($count % 3 == 0) {
      echo implode( ' | ', $PING) . "<br />";
      $PING = Array();
    }
    $count++;
  }
  echo implode( ' | ', $PING) . "<br />";
?>

Link to comment
Share on other sites

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.