Jump to content

[SOLVED] Need help extracting data and syncing data from 2 different databases, I'm stuck


syclonefx

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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(", ");
	}
?>

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.