Update database
maat
30/07/2009 15:13:00Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$con = mysql_connect("","","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("update", $con);
$xml = simplexml_load_file('XMLProductFeed.xml');
foreach($xml->product as $product){
//<name>
$xmlName = htmlentities(($product->name), ENT_QUOTES, 'UTF-8');
$fieldName = trim(html_entity_decode($xmlName));
//<productEvent>
$fieldEvent = $product->productEvent;
//<priceMinimal>
$fieldpriceMinimal = htmlentities($product->priceMinimal, ENT_QUOTES, 'UTF-8');
mysql_query ("SELECT * FROM ticket WHERE event='$fieldEvent'");
if ($fieldEvent == NULL) {
mysql_query ("INSERT INTO ticket (
name,event,priceMinimal)VALUES (
'$fieldName','$fieldEvent','$fieldpriceMinimal'");
}else{
mysql_query("UPDATE ticket SET
name = '$fieldName',
priceMinimal = '$fieldpriceMinimal'
WHERE event = '$fieldEvent'");
}
}
mysql_close($con);
?>
$con = mysql_connect("","","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("update", $con);
$xml = simplexml_load_file('XMLProductFeed.xml');
foreach($xml->product as $product){
//<name>
$xmlName = htmlentities(($product->name), ENT_QUOTES, 'UTF-8');
$fieldName = trim(html_entity_decode($xmlName));
//<productEvent>
$fieldEvent = $product->productEvent;
//<priceMinimal>
$fieldpriceMinimal = htmlentities($product->priceMinimal, ENT_QUOTES, 'UTF-8');
mysql_query ("SELECT * FROM ticket WHERE event='$fieldEvent'");
if ($fieldEvent == NULL) {
mysql_query ("INSERT INTO ticket (
name,event,priceMinimal)VALUES (
'$fieldName','$fieldEvent','$fieldpriceMinimal'");
}else{
mysql_query("UPDATE ticket SET
name = '$fieldName',
priceMinimal = '$fieldpriceMinimal'
WHERE event = '$fieldEvent'");
}
}
mysql_close($con);
?>
Gewijzigd op 01/01/1970 01:00:00 door Maat
PHP hulp
20/11/2024 17:16:34maat
30/07/2009 15:14:00weet iemand hoe je update en nieuwe import?
Gelieve Niet Bumpen::
Gewijzigd op 01/01/1970 01:00:00 door maat
Emmanuel Delay
31/07/2009 05:09:00Wil je misschien toch eens uitleggen waar je precies mee bezig bent, wat je wil bereiken en wat er fout loopt.
Indien je foutberichten krijgt, welke zijn die dan?
Indien je foutberichten krijgt, welke zijn die dan?