Forum Statistics

  • Forum Members: 4,499
  • Total Threads: 3,656
  • Total Posts: 7
There are 1 users currently browsing forums.

Partner Sites

Reply
Old 04-19-2009, 08:15 PM   #1 (permalink)
 
Status: Account Temporarily Suspended
Join Date: Mar 2009
Posts: 52

Rep Power: 0 kuma.lk is on a distinguished road



Default Automatically updating database

Hello,

I currently have a webshop with products that are shipped from a big wholesaler under my name. This wholesaler has a database with all the products in it which also contains the variable "status" which contains information if the product is on stock or not.

I use this code:

<?php require_once('Connections/sosql.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_sosql, $sosql);
$query_Recordset1 = "SELECT * FROM product";
$Recordset1 = mysql_query($query_Recordset1, $sosql) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cron - update voorraadstatus</title>
</head>
<body>
<?php

$login = "#*$!X";
$password = "#*$!X";

// index number for status field
$voorraadIndex = 10;

// index number for product ID
$productidIndex = 0;

$filename =
"http://example.com/retail/prijslijst_excel.php"
."?veldenkiezer=TRUE=&tilde=TRUE&productid=on&verk oopprijs=on"
."&naam=on&omschrijving=on&info=on&inkoopprijs=on& categorie=on"
."&merk=on&voorraad=on&btw=on&gewicht=on"
."&admin_username=".$login
."&admin_password=".$password;

$lines = file($filename);
foreach ($lines as $line) {
$columns = explode('"~"', $line);
$voorraad = mysql_real_escape_string($columns[$voorraadIndex]);
$productid = mysql_real_escape_string($columns[$productidIndex]);
$query = "
SELECT COUNT(*) FROM `testuh`
WHERE id ='{$productid}'
";
$result = mysql_query($query);
$hits = (integer) mysql_result($result, 0, 0);
if ($hits == 1) {
$query = "
UPDATE `testuh` SET `levertijd`='{$voorraad}'
WHERE id ='{$productid}'
";
$update = mysql_query($query);
}
}
?>

This code works fine now. However, I still have a few questions:
1. is it possible to give products that havent matched any of the id numbers of the wholesaler a status code EOL (end of life) so that I do not need to delete deleted items at the wholesaler, but I can just update their status so they cant be ordered anymore?
2. Is there any danger when updating that empty fields are imputted (because of error or something)? This would be very bad because empty "voorraad"/staus fields means the product cant be ordered.

Hope to hear what you guyz think about this.
__________________________________________________ _____________________
apartments in Austin
Glossary of Accounting Software Terms
kuma.lk is offline Add Infraction for kuma.lk   Reply With Quote
Old 07-01-2011, 10:27 AM   #2 (permalink)
 
Status: FG know it all
Join Date: Oct 2009
Posts: 138

Rep Power: 24 Dorothy456 is on a distinguished road



Default

I don't Have any Idea About it . You Should Talk With database Consultant .
Dorothy456 is offline Add Infraction for Dorothy456   Reply With Quote
Old 11-28-2011, 09:16 PM   #3 (permalink)
leonidasbourne
 
Status: Guest
Posts: n/a



Default

You use triger and procedure in database to update your database and there are so many options like when you want to update and change your database, by writing code you can do it also
  Edit/Delete Message Reply With Quote
Old 11-28-2011, 09:22 PM   #4 (permalink)
leonidasbourne
 
Status: Guest
Posts: n/a



Default

You use triger and procedure in database to update your database and there are so many options like when you want to update and change your database, by writing code you can do it also
  Edit/Delete Message Reply With Quote
Old 11-30-2011, 09:34 PM   #5 (permalink)
logginnoff
 
Status: Guest
Posts: n/a



Default кондиционеры


  Edit/Delete Message Reply With Quote
Old 12-02-2011, 03:31 PM   #6 (permalink)
TopBrandsS
 
Status: Guest
Posts: n/a



Default Nulled Scripts - Cap Brands 2k12

Nulled Scripts - Top Brands 2k12 - best software...

During my scrutiny about 64 and 32 tittle operating practice I initiate scads people contradictory surrounding what computer they should pay for or what bit approach they should prefer…I over this article should be a great serve an eye to people to decide the reprove gismo in place of their use.
  Edit/Delete Message Reply With Quote
Old 12-04-2011, 07:15 AM   #7 (permalink)
Idoniaeuh
 
Status: Guest
Posts: n/a



Default cheap nfl jerseys

Cheap nfl jerseys, cheap nba jerseys are hitting the market!!
  Edit/Delete Message Reply With Quote


Reply

Bookmarks

Tags
None


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may post new threads
You may post replies
You may post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.5.0 RC2