Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

update price with search + txt field


Salvo

Recommended Posts

Hi all

 

I have downloaded the price update search and works well if I only use it to update prices.

 

But I have added an other field called products_tel . it is a varchar field, but it only accept NUMERICAL..

 

Can somebody have a look at it and tell me where I go wrong?

 

<?php

/*

$Id: aumento_search.php,v 1.29 2003/04/28 15:32:22 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Author: michele gobbi

email: [email protected]

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

// category drop down

$sql3 = mysql_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");

 

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<style type="text/css">

<!--

th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; background-color: #eeeeee}

/*table { border: #666666; border-style: dashed; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}*/

/*td { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px}*/

td.left { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px; text-align: right; padding-right: 16px}

 

-->

</style>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo "Quick Price Update" ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td align="left">

<?

if ($action == "search") {

echo "<form name=\"update\" method=\"post\" action=\"".$_SERVER["PHP_SELF"]."?action=update_prices\">";

echo "<table>";

echo "<tr><th>Product ID</th><th>Title</th><th>Price</th><th>Telephone</th></tr><tr>";

$result = mysql_query("SELECT * FROM products, products_description WHERE (products.products_model like '%$search%' OR products_description.products_name like '%$search%') AND products.products_id = products_description.products_id AND products_description.language_id = 1");

if ($row = mysql_fetch_array($result)) {

do {

$prezzo=round($row['products_price'],2);

$telefono=$row['products_tel'];

echo "<td align=\"center\">".$row["products_model"]."</td>\n";

echo "<td>".$row["products_name"]."</td>\n";

echo "<td align=\"center\"><input type=\"text\" name=\"product_new_price[".$row['products_id']."]\" value=\"$prezzo\"></td>\n";

echo "<td align=\"center\"><input type=\"text\" name=\"product_new_tel[".$row['products_id']."]\" value=\"$telefono\"></td>\n";

echo "</tr>\n";

}

while($row = mysql_fetch_array($result));

}

echo "</table>\n";

echo "<br><input type=\"submit\" value=\"Update the prices\">";

echo "</form><br><hr><br>";

}

if ($action == "update_prices") {

foreach($HTTP_POST_VARS['product_new_price'] as $id => $new_price) {

mysql_query("UPDATE products SET products_price=$new_price WHERE products_id=$id");

}

 

foreach($HTTP_POST_VARS['product_new_tel'] as $id => $new_tel) {

mysql_query("UPDATE products SET products_tel=$new_tel WHERE products_id=$id");

}

$random = date("U");

echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>Prezzi or Tel aggiornati!!</b></font></p>";

}

?>

<form name="update" method="post" action="<?=$_SERVER["PHP_SELF"]?>?action=search">

<table>

<tr>

<th colspan="2">Which product do you want to search for?</td>

</tr>

<tr>

<td colspan="2"><br></td>

</tr>

<tr>

<td>

Product or Model Number:

</td>

<td>

<input type="text" name="search">

</td>

</tr>

<tr>

<td>

</td>

<td>

<input type="submit" value="Search">

</td>

</tr>

</table>

</form>

</td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

This would be to update the MODEL BUT does not work. can anybody look at this?

 

Thanks

 

<?php

/*

$Id: aumento_search.php,v 1.29 2003/04/28 15:32:22 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Author: michele gobbi

email: [email protected]

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

// category drop down

$sql3 = mysql_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");

 

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<style type="text/css">

<!--

th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; background-color: #eeeeee}

/*table { border: #666666; border-style: dashed; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}*/

/*td { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px}*/

td.left { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px; text-align: right; padding-right: 16px}

 

-->

</style>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo "Quick Price Update" ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td align="left">

<?

if ($action == "search") {

echo "<form name=\"update\" method=\"post\" action=\"".$_SERVER["PHP_SELF"]."?action=update_prices\">";

echo "<table>";

echo "<tr><th>Product ID</th><th>Title</th><th>Price</th><th>Telephone</th></tr><tr>";

$result = mysql_query("SELECT * FROM products, products_description WHERE (products.products_model like '%$search%' OR products_description.products_name like '%$search%') AND products.products_id = products_description.products_id AND products_description.language_id = 1");

if ($row = mysql_fetch_array($result)) {

do {

$prezzo=round($row['products_price'],2);

$model=$row['products_model'];

echo "<td align=\"center\">".$row["products_model"]."</td>\n";

echo "<td>".$row["products_name"]."</td>\n";

echo "<td align=\"center\"><input type=\"text\" name=\"product_new_price[".$row['products_id']."]\" value=\"$prezzo\"></td>\n";

echo "<td align=\"center\"><input type=\"text\" size=\"30\" name=\"product_new_model[".$row['products_id']."]\" value=\"$model\"></td>\n";

echo "</tr>\n";

}

while($row = mysql_fetch_array($result));

}

echo "</table>\n";

echo "<br><input type=\"submit\" value=\"Update the prices &/or telephone\">";

echo "</form><br><hr><br>";

}

if ($action == "update_prices") {

foreach($HTTP_POST_VARS['product_new_price'] as $id => $new_price) {

mysql_query("UPDATE products SET products_price=$new_price WHERE products_id=$id");

}

 

foreach($HTTP_POST_VARS['product_new_model'] as $id => $new_model) {

mysql_query("UPDATE products SET products_model=$new_model WHERE products_id=$id");

}

$random = date("U");

echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>Prezzi or Tel aggiornati!!</b></font></p>";

}

?>

<form name="update" method="post" action="<?=$_SERVER["PHP_SELF"]?>?action=search">

<table>

<tr>

<th colspan="2">Which product do you want to search for?</td>

</tr>

<tr>

<td colspan="2"><br></td>

</tr>

<tr>

<td>

Product or Model Number:

</td>

<td>

<input type="text" name="search">

</td>

</tr>

<tr>

<td>

</td>

<td>

<input type="submit" value="Search">

</td>

</tr>

</table>

</form>

</td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...