fat_dog Posted October 12, 2006 Posted October 12, 2006 Hi there, I'm trying to write a little mod that will allow me to, when adding a product to OSC, tell it that I haven't uploaded the correct/permanent image so that it can be taken and added at a later date. (Mods that tell you when an image isn't present are no good as I plan to add a temporary "Not Available" image to the item). Basically I have added to admin/categories.php a drop-down titles "Image Available?" with a Yes/No option. If the image is available, we select Yes and forget about it. However if we don't have an image, we select No and that is saved to the SQL table "products" under products_no_image as the number 0 (would be 1 for yes). That's what I have done so far and it is working and saving (see screenshot). What I now need to do is create another page that will list all the products where products_no_image is set to 0. Help meeee! I'm learning slowly, but don't know how to get products to list over and over for this sort of option. Can someone please help me with a page that will list these? All we really need is product code and product names to list down the page so we can go and take the picture, then edit it later on by adding the picture to the product, changing the dropdown to Yes and saving. I hope to turn this into a contribution once I get it working and all references will be given for those that help. Many many thanks in advance!
Guest Posted October 18, 2006 Posted October 18, 2006 Why not adapt the "View all Products" Contrib, and at the top just add a switch if prods_image="1" echo blaaa
jfrey Posted October 18, 2006 Posted October 18, 2006 Can anyone help with this? I don't know what you mean by "product code", products_id? or products_model? Anyway, go to phpmyadmin and execute this query: SELECT p.`products_id`, `products_model`, `products_name` FROM `products` p, `products_description` pd WHERE pd.products_id = p.products_id and product_no_image = 0 At the bottom of the page export to csv for excel and then import into Excel.
fat_dog Posted October 18, 2006 Author Posted October 18, 2006 SELECT p.`products_id`, `products_model`, `products_name` FROM `products` p, `products_description` pd WHERE pd.products_id = p.products_id and product_no_image = 0 That sounds along the right lines, however instead of running that in phpmyadmin I aim to put it on a page within admin. Now what I need to to is print that sql query down the page - but how do I script that in PHP to list all values that match, one product after another?
fat_dog Posted October 18, 2006 Author Posted October 18, 2006 I've come up with this but it doesn't display anything (no errors, but no list either!). <?php $no_image_query = tep_db_query("SELECT p.products_id, p.products_model, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd WHERE pd.products_id = p.products_id and p.products_no_image = 0 order by pd.products_name"); $no_image = tep_db_fetch_array($no_image_query); echo $no_image['products_model']; echo $no_image['products_name']; ?>
jfrey Posted October 19, 2006 Posted October 19, 2006 I've come up with this but it doesn't display anything (no errors, but no list either!). <?php $no_image_query = tep_db_query("SELECT p.products_id, p.products_model, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd WHERE pd.products_id = p.products_id and p.products_no_image = 0 order by pd.products_name"); $no_image = tep_db_fetch_array($no_image_query); echo $no_image['products_model']; echo $no_image['products_name']; ?> You aren't getting anything because the result is an array. You need something like: while ($row = mysql_fetch_array($no_image_query, MYSQL_NUM)) { echo $no_image ....; } mysql_free_result($no_image_query); Have to go now.
squeekit Posted October 19, 2006 Posted October 19, 2006 sorry for my late arrival - partic for what i suggest... i haven't used it, and therefore don't know the name of it (i guess i could find out if need be) - there is a contrib that will display a default image if no image has been uploaded... this means you do not need the "yes"/"no" products_no_image feild - instead you could merely have a page display the products with an empty image field BUT if you really want to i suppose you could run the querry on your products_no_image feild too -- you can try jfrey suggestion or do it as it's done for normal product display (the method used in the default 'categories/produsts' page) with something like.... while ($products = tep_db_fetch_array($products_query)) { $products_count++; $rows++; of course there's more to this - let me know how it goes...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.