down2323
down2323
2014-04-16 20:55

PHP / MySQL帮助在分隔符和ID之间解析/提取

  • delimiter
  • php
  • mysql
  • parsing

I've imported data from SharePoint into a MySQL database and I need to extract and format some data out of a string while ignoring the numerical SharePoint IDs in between the delimiters. Example Name field with multiple entries as a string :

Smith, Bob;#5800;#Jones, Mark;#6067;#Brown, Alex

I want the output to look like this:

Smith, Bob</br>
Jones, Mark</br>
Brown, Alex

My current query works and returns the results. Current query:

<?php 
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
while ($row = mysql_fetch_assoc($sql_result)) {
?>
<tr>
  <td><?php echo $row["Project Title"]; ?></td>
  <td><?php echo $row["Project Description"]; ?></td>
  <td><?php echo $row["Project Sponsor(s)"]; ?></td>
</tr>
<?php } ?>

The field containing this particular string is Project Sponsor(s).

How do I parse with these random IDs with the #; delimiter?

Help?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐