Reply
Insert Sql Query
Old 02-01-2005, 12:09 PM Insert Sql Query
Experienced Talker

Posts: 32
I know this is a simple query - i've been looking everywhere in the web for the solution but cannot seem to find it. If any one could help me that would be great.

In my table named Title - i want to replace all blank spaces (" ") with " " in the TITLEID field.

I also want to add values to the Price row dependant on values in the Dealer_price row. For example i want to insert into Price field "20" only where the Dealer_price is "15".

How do i do this? if you need me to explain more clearly then please let me know.

Thanks
hershel is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 02-01-2005, 01:23 PM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
<?

$var = mysql_query("SELECT * FROM Title");
while ($arr = mysql_fetch_array($var)){
$temp = $arr[TITLEID];
$titleid = str_replace(' ', '&nbsp;', $arr[TITLEID]);
mysql_query("UPDATE Title SET TITLEID='$titleid' WHERE TITLEID='$temp'")
}

?>

The code above will replace all of the spaces in your title ID's and change them to &nbsp;'s. As for the other query, I'm not sure what you want, so I'll just write a small thing to make the dealer price a percentage of that of the price.

<?

$percentageoff = '.25'; // Dealer gets 25% off!
$var = mysql_query("SELECT * FROM Title");
while ($arr = mysql_fetch_Array($var)){
$dealerprice = $arr[price]*$percentageoff;
mysql_query("UPDATE Title SET Dealer_price='$dealerpice' WHERE Price='$arr[price]'");
}

?>

That code should change all of the dealer prices to 25% (in your example, 15/20 = 25% off) of the regular price posted, you can change the value of $percentageoff to whatever you'd like.
__________________
Logical Programming - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Reply     « Reply to Insert Sql Query
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11157 seconds with 12 queries