Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MySQL Help for an old veteran. :)


Guest

Recommended Posts

Posted

Can anyone help me with a MySQL statement.

 

I need to replace all occurances of null in the images columns with image_not_available.gif so the default iamge will show up instead of nothing.

 

If this is the wrong way to do it please tell me, as I am semi-retarded at the moment.

 

Also, can I default this field to the image name for future use without blowing anything up?

 

Table: products

 

Fields:

 

products_image

 

products_image_2

 

products_image_3

 

Thanks osC.

 

null.gif

Posted

$query = "UPDATE products SET products_image='image_not_available.gif' WHERE products_image = NULL";

 

tep_db_query($query);

 

Do the same for the others...you can get them all in one shot but I would rather do them one at a time since there are only 3 columns.

 

Next, open phpMyAdmin and select the products table. Select those 3 columns and then edit. Change the default value to the image name. Update. All done.

 

Bobby

Posted

BTW, you can do all this through phpMyAdmin and skip the php code...

UPDATE `products` SET products_image='image_not_available.gif' WHERE products_image = NULL;

Posted

bobby, you are the best man, anything I can do for you please let me know.

 

Thanks alot. and thanks for teh PM on the optimization. !!!!!!!!!!1

 

TJ

 

BTW, you can do all this through phpMyAdmin and skip the php code...

UPDATE `products` SET products_image='image_not_available.gif' WHERE products_image = NULL;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...