Replace same field in all records.

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 1, 2008   (RSS)

By Mowbray - March 30, 2008

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,

Re: [Dave] Replace same field in all records.

By Mowbray - March 31, 2008

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.

Re: [Mowbray] Replace same field in all records.

By Dave - March 31, 2008

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

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

Re: [Dave] Replace same field in all records.

By Mowbray - April 1, 2008

That worked perfectly Dave,
Thanks again.