syclonefx Posted July 7, 2007 Share Posted July 7, 2007 Here is my problem. I need to sync up data from 2 separate databases. The data in the first database is stored in one column, here is an example of the data: 3214, 3478, 3100 These number are the idProduct Primary Key from the Products table of the second database. I need to separate the numbers the coma is the delimiter. each 4 digit number is a different product number from the second database. The site is currently done in ASP and access database. I converted the databases to mySQL and redoing the site in PHP. Here is the code from the asp page is it possible to convert this to PHP? ' the regular expression will be used to filter out numbers from the commas Set REsupplies = New RegExp With REsupplies .Pattern = "[0-9][0-9][0-9][0-9]" .Global = True End With do until rs.eof or rs.bof <% Set expressionmatch = REsupplies.Execute(varSupplies) if expressionmatch.Count > 0 Then For Each expressionmatched in expressionmatch varIdProduct = expressionmatched.Value rs3.filter = "idproduct = "&varIdProduct varProductName = rs3("description") %> <a href="ct_viewItem.asp?idProduct=<%=varIdProduct%>"><%=varProductName%></a><br/> <% Next end if %> I've gotten this far but now I'm not sure how to make each number pull up the records from the other database. <?php $token = strtok ("3213,1234,5454,3100",", "); while($token){ print($token . "<br />"); $token = strtok(", "); } ?> I need to make each 4 digit number pull up the record for the product in the second database. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 7, 2007 Share Posted July 7, 2007 Leave the commas in place and use a query in the form SELECT foo, bar FROM product WHERE idProduct IN (3214, 3478, 3100) Quote Link to comment Share on other sites More sharing options...
syclonefx Posted July 8, 2007 Author Share Posted July 8, 2007 I'm still lost, I'm a complete noob. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2007 Share Posted July 8, 2007 I hate asp, but isn't <% tags for a asp/asp.net or ms framework script? if so this is a php forumn so leave Quote Link to comment Share on other sites More sharing options...
syclonefx Posted July 8, 2007 Author Share Posted July 8, 2007 I hate asp, but isn't <% tags for a asp/asp.net or ms framework script? if so this is a php forumn so leave Yes <% is for ASP. But if you would read my question I am converting an ASP page to PHP and I was giving an example of the ASP code I wanted to convert to PHP. Quote Link to comment Share on other sites More sharing options...
syclonefx Posted July 11, 2007 Author Share Posted July 11, 2007 Thanks for the help guys, I got it to work. <?php $token = strtok ($row_rsGallery['supplies'],", "); while($token){ $query = sprintf("SELECT * FROM products WHERE idProduct = %s AND active = -1",mysql_real_escape_string($token)); $result = mysql_query($query); mysql_query($query) or die("No Products Found"); while ($row = mysql_fetch_assoc($result)){ echo '<a href="shop/product.php?idProduct=' . $row['idProduct'] . '" class="" title="' . $row['description'] . '">' . $row['description'] . '</a><br>'; } $token = strtok(", "); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.