Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

alternate for tep not NULL


updmike

Recommended Posts

I made some mods to have more product info in my store that are very similar to the manufactures ID that gets placed in the products table.

 

I am currently using this code to display the information if it is entered.

if(tep_not_null($product_info['actors_id_14'])){
     $actors_id_14 = $product_info['actors_id_14'];
     $actor_info_query_14= tep_db_query("SELECT  actors_name FROM " . TABLE_ACTORS . " WHERE  actors_id = $actors_id_14");
     $actor_info_14 = tep_db_fetch_array($actor_info_query_14);
	 echo ", ";
	 echo "<a href='actors.php?actors_id=";
	 echo stripslashes($product_info['actors_id_14']);
	 echo "'>";
	 echo stripslashes($actor_info_14['actors_name']); 
	 echo "</a>";
     
	 }

 

And it works fine for what I need to do except for one small glitch. If you change your mind and update the product listing for $actors_id_14 , the database the products table will get set back to 0 instead of NULL.

 

It is the exact same thing that happens when you deselect a manufuature for a product in your database. Is there another option to using

if(tep_not_null($product_info['actors_id_14'])){
do something
}

 

like

if ($product_info['actors_id_14'] != 0 {
then do something
}

 

I am very new to php and still learning all this stuff. I am surpised i got this far with this project and this is a bug that I cant seem to beat?

 

any ideas or suggestion?

 

much Peace, thanks..

Link to comment
Share on other sites

just for the record if anyone searches for this I finally found a solution..

 

if(($product_info['actors_id_23']) !='0'){
     $actors_id_23 = $product_info['actors_id_23'];
     $actor_info_query_23= tep_db_query("SELECT  actors_name FROM " . TABLE_ACTORS . " WHERE  actors_id = $actors_id_23");
     $actor_info_23 = tep_db_fetch_array($actor_info_query_23);
	 echo ", ";
	 echo "<a href='actors.php?actors_id=";
	 echo stripslashes($product_info['actors_id_23']);
	 echo "'>";
	 echo stripslashes($actor_info_23['actors_name']); 
	 echo "</a>";
     
	 }

 

I am sure it is simple enough but since i am only learning php and sql through playing with osC it is usually these little things that stump me.

 

Anyway, since I found that NULL fields get updated to 0 when being edited in admin/catagories.php using !='0' works well. This was the same method that is used for manufucturer info..

 

Peace..

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...