Jump to content

srinivasa

Member
  • Posts

    35
  • Joined

  • Last visited

srinivasa's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. i want to write a generic class say it should contain name,comments and also name field should take only 20 chars and comment field should take 40 chars and also neccessay validation must be done for example name should take only alphabetic chars .....comments should allow only some of the special chars...etc please guide me how to do it.
  2. i want to display image onclick to productname (attached snapshot and code page) i have verified(throuh console) that image is succesfully uploading but need to popup/show image onclik to product name for ex : if i click on sony (which is product name plz have a look at my snapshot) then show image corresponding to that product name) here is the database -- -- Table structure for table `products` -- CREATE TABLE IF NOT EXISTS `products` ( `product_id` int(11) NOT NULL auto_increment, `product_name` varchar(150) NOT NULL, `subcat_id` int(11) NOT NULL, `price` varchar(20) NOT NULL, `description` text NOT NULL, `product_image` varchar(200) NOT NULL, `uploaded_date` varchar(50) NOT NULL, PRIMARY KEY (`product_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; plz reply snapshot.htm product-display.php
  3. //here is my code parts <script type = "text/javascript"> //check all uncheck all function SetAllCheckBoxes(FormName, FieldName, CheckValue) { var ins = document.getElementsByName('mycheckbox[]'); if(CheckValue==false){ for(i=0;i<ins.length;i++) ins.checked=false; } else if(CheckValue==true){ for(i=0;i<ins.length;i++) ins.checked=true; } } //delete all or not function dropdownmenu(select,FormName,FieldName) { var ins = document.getElementsByName('mycheckbox[]'); var i; var j=0; var vals= new Array(); var sentdivvals= new Array(); for(i=0;i<ins.length;i++) { if(ins.checked==true) { vals[j]=ins.value; sentdivvals[j]=divarr.value; j++; } } if((j=='0')&&(select.value!='')) { alert("Please select message(s) using checkbox(es)"); document.myForm.actionDropdown.value=''; return false; } else { <?php @mysql_query("DELETE FROM products WHERE product_id = ");//product id = ????? ?> } } </script> //then form in between some code <input type = checkbox name = 'mycheckbox[]' value = <?php echo $row['product_id'] ?> //then some code <a href=\"javascript:void(0);\" onclick=\"SetAllCheckBoxes('myForm', 'myCheckbox', true);\">Check All</a> / <a href=\"javascript:void(0);\" onclick=\"SetAllCheckBoxes('myForm', 'myCheckbox', false);\">Uncheck All</a></td> <td width = 15% style=\"font-family:verdana;color:gray;font-size:.8pc;\"> <select name=\"actionDropdown\" onchange=\"javascript:dropdownmenu(this,'myForm','myCheckbox');\"> <option value=\"\">With selected:</option> <option value=\"deletemsgs\">Delete</option> </select> //above select part am not getting checked all / unchecked perfectly working but "select part not" plz help me plz ..................here am attaching complete code and snapshot of my page sample.htm product-display.php
  4. your previous reply was given to static data checkbox, actually i had asked for dynamic data where rows are from mysql table..... HERE I HAVE ATTACHED MY WEBPAGE TO SHOW CLEAR SCENARIO ABOUT MY PROBLEM, IN THIS MY PROBLEM IS NOT ABLE TO DELETE ROWS(FROM DATABASE) EXPECTING FAVORABLE REPLY AS SOON AS POSSIBLE............. sample.htm
  5. IMAGINE i have fetched about 8 rows of table data into one webpage and given chekbox to each row, in the same page there are <links to >checkedall/unchekedall followed by select menu 1.delete messages 2.no action should be performed for ex: if i click on checkedall and select the option delete messages it should delete all checked rows(from the main mysql table also) MY PROBLEM IS I DID CODING FOR checkall / uncheckall its working, HOW TO CODE TO DELETE checked rows from mysql table onselecting delete messages from select dropdown. i feel based on primary key of the cheked box i could delete that....HERE I HAVE ATTACHED SNAPSHOT OF MY DESIGN PAGE,THAT WOULD CLEALY EXPLAINS MY PROBLEM......PLZ PLZ DO REPLY please do reply how can i achieve this waiting for your reply, ///////HERE IS THE DATABASE -- -------------------------------------------------------- -- -- Table structure for table `products` -- CREATE TABLE IF NOT EXISTS `products` ( `product_id` int(11) NOT NULL auto_increment, `product_name` varchar(150) NOT NULL, `subcat_id` int(11) NOT NULL, `price` varchar(20) NOT NULL, `description` text NOT NULL, `product_image` varchar(200) NOT NULL, `uploaded_date` varchar(50) NOT NULL, PRIMARY KEY (`product_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- --------------------------------------------------------
  6. //here is the code <?php session_start(); ?> <html> <head><title>Add Product</title> <!--FOR ADD-PRODUCT FORM--> <script type="text/javascript" src="ADD-PRODUCT.js"></script> <link rel = stylesheet href = "design.css" type = "text/css"> <!--category selection--> <script type = "text/javascript"> function showSelectedIndex(){ i = document.product.firstbox.selectedIndex; cat_val=document.product.firstbox.options.value; self.location = 'add-product.php?firstbox='+cat_val; } </script> </head> <body> <!--CONNECT DATABASE--> <?php include('connect-db.php'); ?> <!--topmost--> <table width = "100%" height = "10%"> <tr> <td style="font-family:impact;color:gray;font-size:1.5pc;text-indent:80px">THE PRODUCT STORE</td> <td style="font-family:verdana;font-size:.8pc;font-weight:bold;text-align:right;color:gray"><a href = logout.php>Logout</a></td> </tr> </table><br> <!--middle--> <table width = "100%" height = "100%"> <tr valign = "top"> <td div class = "left"></div></td> <!--content--> <td div class = "middle"> <table width = 100%><tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>ADD PRODUCT:</td> <td style="font-family:verdana;color:gray;font-size:0.7pc;text-align:right" width = 32%><a href = add-product.php>Add Products</a> |</td> <td style="font-family:verdana;color:gray;font-size:0.7pc;text-align:right" width = 18%><a href = product-display.php>View Products</a></td> </tr></table><br> <!--FORM STARTS HERE------------------------------------------------> <form name = "product" action ='' method = 'post' enctype="multipart/form-data"> <table width = 100% cellpadding = 5> <!--product category--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Category:</td> <td width = 50%> <?php $ddone = @mysql_query("SELECT cat_id,cat_name FROM category");?> <select name = 'firstbox' onChange = 'showSelectedIndex()'> <option> - - - - - - Select Category - - - - - - </option> <?php while($row = mysql_fetch_assoc($ddone)){ $catid = $row['cat_id']; $catname = $row['cat_name']; echo "<option value = \"$catid\"> $catname </option>"; } echo "</select>"; ?> </td> </tr> <!--product sub-category--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Sub-category:</td> <td> <?php @$cat = $_GET['firstbox']; ?> <!--TO HOLD CATEGORY SELECTED DATA--> <script language="JavaScript"> var objlen=document.product.firstbox.length; var selected_cat="<?php echo $cat;?>"; for(var i=0;i < objlen;i++){ if (document.product.firstbox.options.value == selected_cat){ document.product.firstbox.options.selected=true; break; } } </script> <?php $ddtwo = @mysql_query("SELECT * FROM subcategory WHERE cat_id = $cat");?> <select name = 'subcat'> <?php echo "<option> - - - - - - - Sub-Category - - - - - - - </option>"; while($now = mysql_fetch_assoc($ddtwo)){ $subcatid = $now['subcat_id']; $subcatname = $now['subcat_name']; echo "<option value = \"$subcatid\">$subcatname</option>"; } echo "</select>"; ?> </td> </tr> <!--product name--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Name:</td> <td><input type="text" id="pn" name = "pn" value = "" size = 30></td> </tr> <!--product price--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Price:</td> <td><input type="text" id="pp" name = "pp" value = "" size = 30></td> </tr> <!--product description--> <tr> <td valign =top style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Description:</td> <td><textarea cols="23" rows="5" id="pd" name = "pd" value = ""></textarea></td> </tr> </table> <!--product image--> <table cellpadding = 3> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 51%>Product Image:</td> <td width = 35% align = left><input type="file" id="pi" name = "pi" value = ""></td><td></td> </tr> <tr><td></td><td align = right><br><input type = 'submit' name = 'submit' value = 'Submit'></td></tr> </table> </form> </div> </td> <!--FORM ENDS HERE--> <div class = error> <?php // check if the form has been submitted. If it has, start to process the form and save it to the database if (isset($_POST['submit'])) { /* get form data, making sure it is valid $prodcat = mysql_real_escape_string(htmlspecialchars($_POST['firstbox'])); $prodsubcat = mysql_real_escape_string(htmlspecialchars($_POST['subcat'])); $prodname = mysql_real_escape_string(htmlspecialchars($_POST['pn'])); $prodprice = mysql_real_escape_string(htmlspecialchars($_POST['pp'])); $proddesc = addslashes($_POST['pd']); @$prodimage = mysql_real_escape_string(htmlspecialchars($_POST['pi'])); $proddate = date("d/m/Y"); */ $prodcat = $_POST['firstbox']; $prodsubcat = $_POST['subcat']; $prodname = $_POST['pn']; $prodprice = $_POST['pp']; $proddesc = $_POST['pd']; @$prodimage = $_POST['pi']; $proddate = date("d/m/Y"); //PRODUCT CATEGORY if ($prodcat != '- - - - - - Select Category - - - - - -') { $msg = " "; } else { echo"Please Select Product Category!!<br>"; } //PRODUCT SUBCATEGORY if ($prodsubcat != '- - - - - - - Sub-Category - - - - - - -') { $msg = " "; } else { echo"Please Select Product Sub-Category!!<br>"; } // PRODUCT NAME if (preg_match('/^[A-Za-z]{3,20}$/',$prodname)) { $msg = " "; } elseif(empty($prodname)) { echo"Please enter ProductName, its empty!!<br>"; } else { $prodname = NULL; echo 'Enter valid ProductName.<br>'; } // PRODUCT PRICE if (preg_match('/^[0-9]{2,10}$/',$prodprice)) { $msg = " "; } elseif(empty($prodprice)) { echo"Please enter ProductPrice, its empty!!<br>"; } else { $prodprice = NULL; echo 'Enter valid ProductPrice.<br>'; } //PRODUCT DESCRIPTION if (preg_match('/^[\w\n\t\s\r]{2,50}$/',$proddesc)) { $msg = " "; } elseif(empty($proddesc)) { echo"Please enter your ProductDescription, its empty!!<br>"; } else { $proddesc = NULL; echo 'Enter your ProductDescription.<br>'; } //PRODUCT IMAGE validation yet to be done echo "</div>"; // save the data to the database mysql_query("INSERT products SET product_name='$prodname',subcat_id='$prodsubcat',price='$prodprice',description='$proddesc',product_image='$prodimage',uploaded_date='$proddate' ") or die(mysql_error()); } ?> <td div class = "right"></div></td> </tr> </body> </html> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //here is my table -- -------------------------------------------------------- -- -- Table structure for table `products` -- CREATE TABLE IF NOT EXISTS `products` ( `product_id` int(11) NOT NULL auto_increment, `product_name` varchar(150) NOT NULL, `subcat_id` int(11) NOT NULL, `price` varchar(20) NOT NULL, `description` text NOT NULL, `product_image` varchar(200) NOT NULL, `uploaded_date` varchar(50) NOT NULL, PRIMARY KEY (`product_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- plz anybody help me..........
  7. here i have pasted file add-product.php in this first dropdown selecting but suddently disappearing(going to default) but second dropdown which is based on first dropdown is displaying correctly.... (this problem is part of product management store project as mentioned in my previous posts proceeding....) please have a look and give me solution //here is the code <?php session_start(); ?> <html> <head><title>Add Product</title> <!--FOR ADD-PRODUCT FORM--> <script type="text/javascript" src="ADD-PRODUCT.js"></script> <link rel = stylesheet href = "design.css" type = "text/css"> <script type = "text/javascript"> function showSelectedIndex(form){ var val = document.getElementById("firstbox").selectedIndex; self.location = 'add-product.php?firstbox=' + val; } </script> </head> <body> <!--CONNECT DATABASE--> <?php include('connect-db.php'); ?> <!--topmost--> <table width = "100%" height = "10%"> <tr> <td style="font-family:impact;color:gray;font-size:1.5pc;text-indent:80px">THE PRODUCT STORE</td> <td style="font-family:verdana;font-size:.8pc;font-weight:bold;text-align:right;color:gray"><a href = logout.php>Logout</a></td> </tr> </table><br> <!--middle--> <table width = "100%" height = "100%"> <tr valign = "top"> <td div class = "left"></div></td> <!--content--> <td div class = "middle"> <table width = 100%><tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>ADD PRODUCT:</td> <td style="font-family:verdana;color:gray;font-size:0.7pc;text-align:right" width = 32%><a href = add-product.php>Add Products</a> |</td> <td style="font-family:verdana;color:gray;font-size:0.7pc;text-align:right" width = 18%><a href = product-display.php>View Products</a></td> </tr></table><br> <form name = "product" onsubmit="return formValidator()"> <table width = 100% cellpadding = 5> <!--product category--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Category:</td> <td width = 50%> <?php $ddone = @mysql_query("SELECT cat_id,cat_name FROM category"); echo "<select id = 'firstbox' name = 'maincat' onchange = 'showSelectedIndex()'>"; echo "<option> - - - - - - Select Category - - - - - - </option>"; while($row = mysql_fetch_array($ddone)){ $catid = $row['cat_id']; $catname = $row['cat_name']; echo "<option value = \"$catid\"> $catname </option>"; } echo "</select>"; ?> </td> </tr> <!--product sub-category--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Sub-category:</td> <td> <?php @$cat = $_GET['firstbox']; $ddtwo = @mysql_query("SELECT cat_id,subcat_name FROM subcategory WHERE cat_id = $cat"); echo "<select name = 'subcat'>"; echo "<option> - - - - - - - Sub-Category - - - - - - - </option>"; while($now = mysql_fetch_assoc($ddtwo)){ $subcatid = $now['subcat_id']; $subcatname = $now['subcat_name']; echo "<option value = \"$subcatid\">$subcatname</option>"; } echo "</select>"; ?> </td> </tr> <!--product name--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Name:</td> <td><input type="text" name="pn" value = "" size = 30></td> </tr> <!--product price--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Price:</td> <td><input type="text" name="pp" value = "" size = 30></td> </tr> <!--product description--> <tr> <td valign =top style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Description:</td> <td><textarea cols="23" rows="5" name="pd"></textarea></td> </tr> </table> <!--product image--> <table cellpadding = 3> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 51%>Product Image:</td> <td width = 35% align = left><input type="file" name="pi" value = ""></td><td></td> </tr> <tr><td></td><td align = right><br><input type = submit name = 'submit' value = 'submit'></td></tr> </table> </form> </div> </td> <td div class = "right"></div></td> </tr> </body> </html>
  8. i have uploaded add-product.php in my previous post and made some modificatiosns,also pasted part of the code with some modifications...for quick review ///category code part in add-product.php//// <!--product category--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Category:</td> <td width = 50%> <?php $ddone = @mysql_query("SELECT cat_id,cat_name FROM category"); echo "<select name = 'maincat'>"; while($row = mysql_fetch_assoc($ddone)){ $catid = $row['cat_id']; $catname = $row['cat_name']; echo "<option value = \"$catid\"> $catname </option>"; } echo "</select>"; ?> </td> </tr> ///ends here ///subcategory followed by above in php file <!--product sub-category--> <tr> <td style="font-family:verdana;color:gray;font-size:.8pc;font-weight:bold;"width = 50%>Product Sub-category:</td> <td> <?php $ddtwo = @mysql_query("SELECT cat_id,subcat_name FROM subcategory WHERE cat_id = $catid"); echo "<select name = 'subcat'>"; while($now = mysql_fetch_assoc($ddtwo)){ $subcatid = $now['subcat_id']; $subcatname = $now['subcat_name']; echo "<option value = \"$subcatid\">$subcatname</option>"; } echo "</select>"; ?> </td> </tr> ///subcategory ends here now my problem is irrespective of main category selection it showing subcategory as tables and chairs but it shd change according to main category selection,plz have a look at my code and give me solution (i have uploaded my database i.e products.sql in my previous post) i think am failing in catching the first dropdown menu value or displaying in second dropdown .... for my above result it must have always selecting cat_id as 4 it seems.... sir.............plz plz help me
  9. i agree to you,please have a look at my code, i have to retrive data from mysql table to the form ,in my code i have successfully retrieved data from category table,am failing to retrieve data from subcategory table which should be based on the category selected item.....please help me
  10. thanks for your previous replies, now am designing a page called add-product as a part of the project 'product management store' my problem is how to design dropdown based on the previour dropdown selection (using php and mysql) (i.e according to my database and table data if i select electronic goods from category drop down i should be able to see only items pertained to electronic items in the second drop down menu category - electonic goods subcategory - laptops computer television should be there...but in my design its showing all subcategories...i have attached my database file and add-product.php file for your review...plz reply soon....................... AND also suggest me how to upload image and handling image products.zip add-product.php
  11. I would very grateful to you for your invaluable replies to my previous queries(admin not working post) now admin login is succesful...then i shd redirect to page(yet to design) as shown in the image file that i have attached with these criteria i have created database and tables(that also uploaded) Product Store listing page *This page will list all the products from all product categories and all sub- categories. *On click of any product name the product image should open as a popup. *Operation column has two things Edit and Delete actions, which a user *can take for any product in the listing page by clicking on the icon Edit and Delete *Edit action should take to Edit Page (yet to design) *Delete action prompt confirmation message asking” Do you want to delete: Yes or No” *To delete multiple products in one action use Check All/Uncheck All then *select from drop down menu Delete like any mailbox. *Pagination required like maximum of 8 products. (Each page would display as shown in image file) so please give me ideas where shd i start to achieve designing this...... waiting for your reply.......... srinivas project.zip
  12. Thanks your suggestions hepls me a lot, ITS WORKING NOW EXCEPT SMALL PART HERE BY I DO ATTACH MY FILES FOR YOUR REVIEW else{echo"Wrong Username Or Password";} //IN log.php THIS above PART is not showing on wrong user/pass(just giving blank page) please reply soon.............. PROJECT.zip
×
×
  • Create New...