Home > MySQL, PHP > Php Mysql Change Code

Php Mysql Change Code

November 26th, 2009

Original code

Table 1
id
userid
site
subject
adbody
url

foreach($id as $each) {
mysql_query (”update 1 set approved=1 where id=”.$each);
// the above code marks the home site data as approved

$sql = mysql_query(”SELECT * FROM 1 WHERE id=”.$each);
$info = mysql_fetch_array($sql);

// Work out the data
$wannasay = array (
“userid” => $info['userid'],
“site” => $info['site'],
“subject” => $info['subject'],
“adbody” => $info['adbody'],
“url” => $domain.”/click.php?id=”.$info['id']
// The data above sends the data to other sites so
// if the home site is xyz.com the other site would
// receive http://www.xyz.com/click.php?id=”X”
);

So in the above case if the url in the table 1 was http://www.google.com then it stays
that way at the home site but the other sites would get http://www.xyz.com/click.php?id=”X’

I need to change this up and need new code for it to work this way.

The main site (paul) holds the data in table ‘holding’
then when the code is executed I need it to submit the data to the other sites.

In this example our table data would look like

Table holding
id = 1
userid = joe
site = henry
subject = test subject
adbody = test adbody
url = http://www.google.com

Then on the main site ‘paul’ the ad would be approved and the ad is sent to the other sites.

The way I need it to work is IF the ad come from the same site then the url is left
http://www.google.com else it needs to check where it is sending and change the url
to the correct domain.

So IF site=henry then the url is http://www.google.com
else if the site is not equal to henry then change the domain accordingly.

For example

IF site from 1(id) =henry url is http://www.google.com
else all the other sites in the network receive the url
as http://www.henry.com/click.php?id=”X’

So a break down

Say there are 10 sites in this network with paul.com being the main site.

The original ad came from henry.com to paul.com and was inserted into

Table holding
id = 1
userid = joe
site = henry
subject = test subject
adbody = test adbody
url = http://www.google.com

The admin at paul.com approves the ad and sends it to all the sites in the network,
when it goes back to henry.com the url is http://www.google.com but when it goes
to the other sites it is http://www.henry.com/click.php?id=”X’

and of course if the original ad was submitted by bill.com then the url
is the originally submitted url when sent back to bill.com and
http://www.bill.com/click.php?id=”X’ when sent to the other 9 sites
in the network.


Php Mysql Change Code

Categories: MySQL, PHP Tags: , , , , , ,