Replace same field in all records.

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

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

By Dave - March 31, 2008

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

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.