Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Replace same field in all records.

 

 


Mowbray
User

Mar 30, 2008, 6:13 PM

Post #1 of 5 (307 views)
Shortcut
Replace same field in all records. Can't Post

Hi,
This forum is getting a lot of posts from me these days.

I was wondering if it was possible to take a field like "web_url" that is in ever product listed in productList.php and replace it with a specific value.

For instance, I want to direct anyone who would click a link that would use web_url to contact_usPage.php instead. So I'd need to replace all of the "web_url"s in all of the product records to say "contact_usPage.php" instead of whatever they contain.

Is there a moderately simple way to do this?

Thanks,


Dave
Staff / Moderator


Mar 31, 2008, 1:19 PM

Post #2 of 5 (283 views)
Shortcut
Re: [Mowbray] Replace same field in all records. [In reply to] Can't Post

Hi Mowbray,

If you needed to update _every_ record, the simplest might just be to hardcode the value into the viewer php page. So instead of <?php echo $record['web_url'] ?> you'd put in the url to contact_usPage.php. Would that work?

Dave Edis - Senior Developer
interactivetools.com


Mowbray
User

Mar 31, 2008, 5:43 PM

Post #3 of 5 (278 views)
Shortcut
Re: [Dave] Replace same field in all records. [In reply to] Can't Post

Yes... but...
It would work, I could just hard code it in, but that would eliminate any changes becoming visible. It's meant to be a temporary thing until the client has time to enter in the ACTUAL url that she wants to link to.

So if the record hadn't had a new entry put in by the client it would direct to the contact page, but if she has had time to enter a url in that record it would direct to whatever she enters.


Dave
Staff / Moderator


Mar 31, 2008, 6:21 PM

Post #4 of 5 (276 views)
Shortcut
Re: [Mowbray] Replace same field in all records. [In reply to] Can't Post

I understand. Ok, try this. In your list viewer (productList.php) add this code just below "require_once":


Code
require_once "lib/viewer_functions.php"; 
$updateQuery = "UPDATE {$TABLE_PREFIX}product SET web_url='http://www.google.com/'";
mysql_query($updateQuery) or die("MySQL Update Error: {mysql_error()}\nQuery: $updateQuery");


Just double check all the parts in red to make sure they match the values on your system and then open productList.php in your browser. It will update all the field values for _every_ record. Once you're done remove those lines.

Hope that helps! Let me know how it works out.

Dave Edis - Senior Developer
interactivetools.com


Mowbray
User

Apr 1, 2008, 7:41 AM

Post #5 of 5 (260 views)
Shortcut
Re: [Dave] Replace same field in all records. [In reply to] Can't Post

That worked perfectly Dave,
Thanks again.

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4