I working on a way to take information in a mysql record field that is comma delimited (e.g. "000001,000012") and then match it with its corresponding id number is another mysql database.
For instance the second mysql database the record ID "000001" is named "Home" and record ID "000012" is named "Work."
What I wanting to do is to have php script to display the comma delimited information and display it with the names of the records in the second mysql database.
In other words, I want to display (000001,000012) as (Home, Work).
How can I do this? I'm new to php and I'm at a lost.
String Help
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
This is generally called linking, or referencing. It can be suggested to not store a comma delimited array in a table when a simpler solution is available. I'm going to assume that these comma delimited sets are attached to someone or something, where each can have access to variant numbers of these records. This is a many-to-many relationship. These set up's usually require 3 tables. 2 data tables, and a link between the two. There are a few recent threads in the database forum that talk about many-to-many relationships and their set up.
strings and arrays
if both data sets are coming from two different db's then you will probably not be able to do the join, if they are from the same db and different tables then they joining table would be the best.
However if the first is true you will have to loop through your dataset and doing string comparrisions to match the data.
By they way it is great to be back after not having regular access for so long.

However if the first is true you will have to loop through your dataset and doing string comparrisions to match the data.
By they way it is great to be back after not having regular access for so long.
Found a way of doing this with the following script.
Thanks to everyone who gave me suggestions 
Code: Select all
<?php
do {
if(strpos($row_rsLaos['scell'],$row_rsCellmenu['id'])!==FALSE)
{
echo $row_rsCellmenu['name'].', ';
}
}
while ($row_rsCellmenu = mysql_fetch_assoc($rsCellmenu));
?>