Jump to content

saravanataee

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by saravanataee

  1. Dear all, I have a php page in which i have three div's. Each one has a query and set of results which i display row by row inside the div. My div3 is the one will have more records say 150 rows. So, i wanna apply pagination such that 4 records will be shown in each page. But, i would i go about applying single pagination that will be applied for all the three div's. becuz we input numbers of records returned by a query to pagination counter. But since i had three queries which one to be assiged. Might be div3 that has large records. But not sure.. Please help me on this. <?php $subcat=$_REQUEST['subcat']; include_once('inc/dbConnect.inc.php'); include_once('inc/pagination.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TopAds India</title> <link href="default.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="js/jquery.easing.1.3.js"></script> <script type="text/javascript" src="js/sprite.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("ul#nav li a").css({"opacity" : 0}).hover(function(){ $(this).stop().animate({"opacity" : 1}, 200); //Change fade-in speed }, function(){ $(this).stop().animate({"opacity" : 0}, 100);//Change fade-out speed }); }); </script> <script type="text/javascript" language="javascript" src="js/jquery.suSlider.js" ></script> <script type="text/javascript" language="javascript" > $(document).ready(function(){ loop(); function loop(){ $('#sildercontent').suSlider({ mode: 'slide', speed: 1500, select:12000, auto:true, wrapper_class: 'portfolio_container' }); } //On mouseover stop the slider $("#sildercontent").mouseover(function() { $(this).stop(); return false; }); //On mouseout start the slider $("#sildercontent").mouseout(function() { loop(); }); }); </script> </head> <body onload="changePagination('0','first')"> <div id="wrap"> <div id="header"> <table align="center" width="905px" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table align="center" width="905px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="174" valign="top" style="padding-top:10px;"><img src="images/logo.png" alt="TopAdsIndia" /></td> <td width="313" valign="top"><img src="images/logo_txt.png" alt="." width="313" height="128" /></td> <td width="418" align="right" valign="bottom" style="padding-right:0px;"><a href="post.php?post_type=1"><img src="images/post_free.png"alt="." border="0" width="168" height="53" /></a></td> </tr> </table> </td> </tr> <tr> <td> <table align="center" width="905px" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div id="page-wrap"> <div id="content"> <ul id="nav"> <li class="home"><a href="index.php">Home</a></li> <li class="aboutus"><a href="#">About Us</a></li> <li class="highlight_ads"><a href="highlighted.php">Highlight Ads</a></li> <li class="premium_ads"><a href="premium.php">Premium Ads</a></li> <li class="gallery_ads"><a href="gallery.php">Gallery Ads</a></li> <li class="contact"><a href="contact_us.php">Contact Us</a></li> </ul> </div> </div> </td> </tr> </table> </td> </tr> </table> </div> <div id="main"> <table align="center" width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="740" valign="top"><table align="left" width="740" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="740"><table align="left" width="740" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="740"> </td> </tr> <tr> <td width="740" style="padding-left:20px; padding-bottom:10px;"><h2>Premium Ad's</h2></td> </tr> <tr> <td> <div id="table1"> <?php require('config.php'); $query="select * from temp_ad_table WHERE post_type=3 AND Subcategory='$subcat'"; $result=mysql_query($query); if(mysql_num_rows($result)==0 ){ echo '<font color="red" size="5">No Post Found in this Category</font>'; }else { while($row = mysql_fetch_assoc($result)) { ?> <?php $id=$row['ad_id'];?> <div class="premium-listingpagePosts"> <div class="premium-listingpagePostsLeft"> <img src="<?php echo $row['image_location']; ?>"> </div> <div class="premium-listingpagePostsRight"> <div class="premiumslider-postsHeading"><a href="view.php?ad_id=<?php echo $id; ?>""><?php echo $row['Name'];?></a></div> <div class="premium-postsDesc"> <p> <b>Description:</b><?php echo substr(strip_tags($row['AddtionalDt']), 0, 100). "......"; ?> </p> </div> </div> <div class="premium-listingpagePostsRight2" style="vertical-align:top;"> <img src="images/Premium_Ad.png" alt="Premium Ads" border="0"> </div> </div> <div class='clear'></div> <?php } } ?> </div> </div> </div> <div id="table2"> <h2>Highlighted/Free Ad's</h2><br/> <div style="border:2px solid #343233;"> <div id="pageData2" > <?php $query1="select * from temp_ad_table"; $res1=mysql_query($query1); $count1=mysql_num_rows($res1); if($count1 > 0) { $paginationCount=getPagination($count1); } if(isset($_GET['page'])) { $pageLimit = ($_GET['page'] - 1) * 5; } else { $pageLimit = 0; } $query2="select * from temp_ad_table WHERE Subcategory='$subcat' AND (post_type=2 OR post_type=1) ORDER BY `post_type` DESC, `Date` DESC limit $pageLimit,5"; $res2=mysql_query($query2); $count2=mysql_num_rows($res2); if($count2 > 0){ while($row2=mysql_fetch_array($res2)){ $ad_id = $row2['ad_id']; $AdName=$row2['Name']; $addtitle=$row2['AddTitle']; $description=$row2['AddtionalDt']; $location=$row2['Location']; $image=$row2['image_location']; $h_ads = 'yellow'; $post_type=$row2['post_type']; if($post_type == 1) { $h_ads = 'style="background: #e8e8e8;"'; //$h_ads = '<span class='freeads-listingpagePosts'>' ; //$h_ads .= '</span>'; //$h_ads = "<span class='freeads-listingpagePosts'></span>"; } ?> <div class="highlight-listingpagePosts" <?php echo $h_ads; ?>> <div class="highlight-listingpagePostsLeft"> <img src="<?php echo $image; ?>"> </div> <div class="highlight-listingpagePostsRight"> <div class="highlight-postsHeading"> <?php if($post_type==2){?> <a href="view2.php?ad_id=<?php echo $ad_id; ?>"><?php echo $AdName; ?></a> <?php } else {?> <a href="view3.php?ad_id=<?php echo $ad_id; ?>"><?php echo $AdName; ?></a> <?php } ?> </div> <div class="highlight-postsDesc"><?php echo substr(strip_tags($row2['AddtionalDt']), 0, 100). "......"; ?></div><br/> </div><br/> </div> <div class='clear'></div> <?php }} else{ echo '<font color="red" size="5">No Post Found in this Category</font>'; } ?> </div> <?php if($count2 > 0){ ?> <div id="pag"><ul> <li class='first link' id="first"><a href="dashboard.php">First</a></li> <?php for($i=1;$i<$paginationCount+1;$i++){ ?><li class='link'><a href="?page=<?php echo $i; ?>"><?php echo $i;?></a></li><?php } ?> <li class='last link' id="last"><a href="?page=<?php echo $i-1; ?>">Last</a></li> <li class="flash"></li> </ul></div><br><br> <?php } ?> </div> </div> </td> </tr> </table> </td> </tr> </table></td> <td width="165" valign="top"><table width="165px" align="right" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> <tr><td style="padding-bottom:10px;"><h2>Gallery Ad's</h2></td></tr> <tr> <td style="background-color:#cceaee; -webkit-border-radius: 10px; -moz-border-radius: 10px;border-radius: 10px; height:900px; padding-top:10px;" valign="top"> <div id="table3"> <?php $query3="select * from temp_ad_table WHERE post_type=4 AND Subcategory='$subcat'"; $res3=mysql_query($query3); $count3=mysql_num_rows($res3); if($count3 > 0){ while($row3=mysql_fetch_array($res3)){ $ad_id = $row3['ad_id']; $AdName_gal=$row3['Name']; $addtitle_gal=$row3['AddTitle']; $description_gal=$row3['AddtionalDt']; $location_gal=$row3['Location']; $image_gal=$row3['image_location']; $post_type_gal=$row3['post_type']; ?> <div class="gallery-listingpagePosts"> <div class="gallery-listingpagePostsLeft"> <img src="<?php echo $image_gal; ?>"> </div> <div class="gallery-listingpagePostsRight"> <div class="gallery-postsHeading"> <a href="view4.php?ad_id=<?php echo $ad_id; ?>"><?php echo $AdName_gal; ?></a> </div> <div class="gallery-postsDesc"><?php echo substr(strip_tags($row3['AddtionalDt']), 0, 100). "......"; ?></div><br/> </div><br/> </div> <br/> <?php } } else{ echo'<font color="red" size="5">No Post Found in this Category</font>'; } ?> </div> </td> </tr> <tr> <td> </td> </tr> </table> </td> </tr> </table> </div> <div id="footer"><table align="center" width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="64px"><table width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td style="color:#cfcfcf;" height="64px" valign="middle"><a href="index.php" class="footlink">Home</a> | <a href="#" class="footlink">About Us</a> | <a href="highlighted.php" class="footlink">Highlighted Ads</a> | <a href="premium.php" class="footlink">Premium Ads</a> | <a href="gallery.php" class="footlink">Gallery Ads</a> | <a href="#" class="footlink">Contact Us</a></td> <td><table align="right" width="130" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right"><a href="#"><img src="images/facebook.png" alt="Facebook" border="0" /></a></td> <td align="right"><a href="#"><img src="images/twitter.png" alt="Twitter" border="0" /></td> <td align="right"><a href="#"><img src="images/linkedin.png" alt="Linkedin" border="0" /></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td><table width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" style=" color:#828282; font-size:15px;" valign="middle" height="35px"><table width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" style=" color:#828282; font-size:15px;" valign="middle">Copyright © 2013 TopAdsIndia. All rights reserved. </td> <td align="right"><a href="http://www.liveyourdreamsindia.com" target="_blank"><img src="images/designed.png" alt="Designedby: LiveYourDreamsIndia" border="0" /></a></td> </tr> </table></td> </tr> </table> </td> </tr> </table> </div> </div> </body> </html> In the above code, div id table2 has large no of records in my db. So, i have applied pagination to it. But i wanna apply same to other two div's. please help out.
  2. Dear all, Here is my scenario, I have a php page called index.php which is linked to dashboard. At the index page i will have 40-50 href's each with a id like dashboard.php/subcat=1 When a user click's particular href they will be forwarded to a page called dashboard and there i get this id. $subcat=$_REQUEST['subcat']; This dashboard is dynamic. In this page i have three different div's. Each with different query and result display. For example: My first div has a query and some 50 results. I want a display first four rows and remaining as a ajax pagination. similarly for the other two div's. There is no problem in using ajax pagination because it will be executed in different page and result will be display here. But the real problem is in each of my query i should pass the original subcat id which is what make the dashboard dynamic. Now, i need someway to pass this dynamic id for my external pagination for each query.
  3. I just executed the query into $query=mysql_query("query"); print_r($query); output is: Array ( [0] => 1 [product_id] => 1 [1] => 19103 [ponumbers] => 19103 [2] => 18410 [gonumbers] => 18410 ) how did u execute it?? am i doing wrong in executing. plz let me know!!
  4. Dear all, I am having the following problem and did not know the solution. I have three related tables. product purchase_order git_order. In product table product_id product_name 1 barrings 2 wheel rim 3 rodd purchase_order po_id product_id package_id numbers received etc. 1 1 2 100 50 2 2 4 250 60 3 1 1 200 40 4 1 3 200 40 5 2 5 200 40 6 1 1 200 40 7 1 5 200 40 git_order git_id product_id package_id numbers received etc. 1 1 2 100 50 2 2 4 250 60 3 1 1 200 40 4 1 3 200 40 5 2 5 200 40 6 2 1 200 40 7 1 5 200 40 The output i want is. product_id sum(numbers)in 2ndtable | sum(numbers)in 3rdtable 1 900 700 2 450 650 i need a query to do this. i m new to this. i spent lot of time in this but couldnt resolve. please help me. This is my present query: SELECT p.product_id, po.ponumbers, g.gonumbers FROM Product p LEFT JOIN (SELECT Product_id, SUM(numbers) AS ponumbers FROM purchase_order GROUP BY product_id ) AS po ON p.product_id = po.product_id LEFT JOIN (SELECT product_id, SUM(numbers) AS gonumbers FROM git_order GROUP BY product_id) AS g ON p.product_id = g.product_id this gives the following output: Array ( [0] => 1 [product_id] => 1 [1] => 19103 [ponumbers] => 19103 [2] => 18410 [gonumbers] => 18410 ) but i want not only for 1 product, i need the query to do the same for all the products that i have in my product table. any help??
  5. Dear members, I m running with the following problem for more than a week but i m not able to sort out. The scenario is that, in one of my php form i m having two dropdown and a text box related to each other. i.e when i select a product from dropdown1, the values of dropdown2 will be sorted based on the value of dropdown1 and similarly based on the value of dropdown2 , the value of textbox will be shown. This i accomplished with the help of ajax and jquery. And also this one working for me very well(shown in the image 1&2 of attachements). But the issue now is, in my product selection, my product list went very long so i had to bring an auto-suggestion. i brought the jquery selection with auto-complete model which has been shown in the same attachment(image3&4). the issue now is, when i select the product from my first dropdown, the second dropdown value is not loading, with firebug i checked, the values are properly retrieved for second dropdwn based on first drpdown but its not shwn up in the value list of second dropdwn. I don know what exactly the problem is. I m thinking it might be the clash of jquery versions that i m using. So, can some sort me out the problem with my form. I have included the form code here. <link rel="stylesheet" href="<?php echo HOME_URL; ?>chosen/chosen.css" /> <style type="text/css"> td { width:800px; } </style> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#product_id").change(function(){ var get_package_url = '<?php echo HOME_URL; ?>select.php'; $.getJSON(get_package_url,{product_id: $(this).val(), ajax: 'true'}, function(j){ var options = ''; options += '<option value="0"> -- Select -- </option>'; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#package_id").html(options); }) }) $("select#package_id").change(function(){ var get_package_url = '<?php echo HOME_URL; ?>select.php'; $.getJSON(get_package_url,{package_id: $(this).val(), ajax: 'true'}, function(j){ for (var i = 0; i < j.length; i++) { var value = j[i].optionDisplay; } $("#package_qty").val(value); }) }) }) </script> <script> $(function() { $( "#datepicker" ).datepicker({ altFormat: "dd-mm-yyyy" }); }); </script> <form action="<?php echo base_url(); ?>purchase_order/add" method="post"> <table border="1"> <tr> <td> <b>Product </b> <select name="product_id" style="width:250px;" data-placeholder="Choose a Supplier..." id="product_id" class="chzn-select"> <option value="0"> -- Select Product -- </option> <?php foreach($get_all_product as $value) { ?> <option value="<?php echo $value['product_id']; ?>"><?php echo $value['product_name']; ?></option> <?php }?> </select> </td> <td> <b>Order Qty </b> <input type="text" name="quantity" value="" style="width:75px;" /></td> <td> <b>Package</b> <select name="package_id" id="package_id"> </select> </td> <td> <b> Qty / Packing</b> <input type="text" name="package_qty" id="package_qty" value="" readonly="readonly" style="width:75px;" /></td> <td colspan="2"> <input type="submit" name="submit" value="Add to Cart" /> </td> </tr> </table> <script src="<?php echo HOME_URL; ?>chosen/chosen.jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script> </form><br/><br/> <?php if($this->cart->contents()) { ?> <h2>Ordered Cart</h2> <br/> <table border="1"> <tr> <td> <b> Product </b> </td> <td> <b> Order Qty</b> </td> <td> <b>Qty/ Packing</b></td> <td> <b> MRP</b> </td> <td align="right"> <b>Amount </b></td> <td align="right"> <b>Action </b></td> </tr> <?php $grand_total = 0; foreach ($this->cart->contents() as $items) { ?> <tr> <td> <?php echo $items['name']; ?></td> <td> <?php echo $items['qty']; ?></td> <td> <?php echo $items['package_qty']; ?></td> <td> <?php echo $items['price'];//money_format('%!i',$items['price']); ?></td> <td align="right"> <?php echo $items['amount'];//money_format('%!i', $items['amount']); $grand_total = $items['amount']+$grand_total; $discount= $grand_total * 40/100; $gross_amount = $grand_total-$discount; ?></td> <td align="right"> Remove </td> </tr> <?php } ?> <tr> <td colspan="5" align="right"><b>Grand Total</b></td> <td align="right"><b><?php echo $grand_total;//money_format('%!i', $grand_total); ?></b></td> </table> <form method="post" action="<?php echo base_url()."purchase_order/create"; ?>"> <BR/> <BR/> Addtional Details : <textarea rows="5" cols="80" name="info"></textarea> <BR/> Date : <input type="text" name="date" value="<?php echo date('d-m-Y'); ?>" /><br/><br/><br/> <h2> Approximate value of Order</h2><br/> <b>Gross Amount:<b><?php echo $grand_total;?><br/> <b>Less Discount @ 40%:<b><?php echo $discount;?><br/> <b>Net Amount:<b><?php echo $gross_amount;?><br/> <input type="submit" name="submit" value="Create PO" /> </form> <?php } ?>
  6. Dear all, I am having a problem. I have a php form where i have triple drop down's connected. i.e I select the value from the 1st dropdown and based on that value 2nd dropdown's value will be loaded and similarly the 3rd one. It works fine as of now. But now suddenly i want to turn the 1st dropdown into a textbox with auto suggestion. I know how to bring auto suggestion in php. But the problem is that, inside the select i have used option value as the id to next select. i.e <select name="product_id" id="product_id"> <option value="0"> -- Select Product -- </option> <?php foreach($get_all_product as $value) { ?> <option value="<?php echo $value['product_id']; ?>"><?php echo $value['product_name']; ?></option> <?php }?> </select> So, i m not able to pass this id if i make the select into a textbox werent i m not allowed to have option value. So can anyone help me over come this issue. I knew ajax or jquery will help me in this. But dono how to proceed with. Any help is must appreciated. My original form code is: <style type="text/css"> td { width:800px; } </style> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#product_id").change(function(){ var get_package_url = '<?php echo HOME_URL; ?>select.php'; $.getJSON(get_package_url,{product_id: $(this).val(), ajax: 'true'}, function(j){ var options = ''; options += '<option value="0"> -- Select -- </option>'; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#package_id").html(options); }) }) $("select#package_id").change(function(){ var get_package_url = '<?php echo HOME_URL; ?>select.php'; $.getJSON(get_package_url,{package_id: $(this).val(), ajax: 'true'}, function(j){ for (var i = 0; i < j.length; i++) { var value = j[i].optionDisplay; } $("#package_qty").val(value); }) }) }) </script> <script> $(function() { $( "#datepicker" ).datepicker({ altFormat: "dd-mm-yyyy" }); }); </script> <form action="<?php echo base_url(); ?>purchase_order/add" method="post"> <table border="1"> <tr> <td> <b>Product </b> <select name="product_id" id="product_id"> <option value="0"> -- Select Product -- </option> <?php foreach($get_all_product as $value) { ?> <option value="<?php echo $value['product_id']; ?>"><?php echo $value['product_name']; ?></option> <?php }?> </select> </td> <td> <b>Order Qty </b> <input type="text" name="quantity" value="" style="width:75px;" /></td> <td> <b>Package</b> <select name="package_id" id="package_id"> </select> </td> <td> <b> Qty / Packing</b> <input type="text" name="package_qty" id="package_qty" value="" readonly="readonly" style="width:75px;" /></td> <td colspan="2"> <input type="submit" name="submit" value="Add to Cart" /> </td> </tr> </table> </form><br/><br/> <?php if($this->cart->contents()) { ?> <h2>Ordered Cart</h2> <br/> <table border="1"> <tr> <td> <b> Product Name </b> </td> <td> <b> Price</b> </td> <td> <b> Package Qty</b> </td> <td> <b>No of Qty </b></td> <td align="right"> <b>Amount </b></td> <td align="right"> <b>Action </b></td> </tr> <?php $grand_total = 0; foreach ($this->cart->contents() as $items) { ?> <tr> <td> <?php echo $items['name']; ?></td> <td> <?php echo $items['price'];//money_format('%!i',$items['price']); ?></td> <td> <?php echo $items['package_qty']; ?></td> <td> <?php echo $items['qty']; ?></td> <td align="right"> <?php echo $items['amount'];//money_format('%!i', $items['amount']); $grand_total = $items['amount']+$grand_total; $discount= $grand_total * 40/100; $gross_amount = $grand_total-$discount; ?></td> <td align="right"> Remove </td> </tr> <?php } ?> <tr> <td colspan="5" align="right"><b>Grand Total</b></td> <td align="right"><b><?php echo $grand_total;//money_format('%!i', $grand_total); ?></b></td> </table> <form method="post" action="<?php echo base_url()."purchase_order/create"; ?>"> Addtional Details : <textarea rows="5" cols="100" name="info"></textarea> Date : <input type="text" name="date" value="<?php echo date('d-m-Y'); ?>" /><br/><br/><br/><br/> <h2> Approximate value of Order</h2><br/> <b>Gross Amount:<b><?php echo $grand_total;?><br/> <b>Less Discount @ 40%:<b><?php echo $discount;?><br/> <b>Net Amount:<b><?php echo $gross_amount;?><br/> <input type="submit" name="submit" value="Create PO" /> </form> <?php } ?> Thanks in advance..!!
  7. Dear all, My new web project is fully based on javascript. Each and every fields and form's have javascrip and ajax call's. So, if any user who comes without any knowledge of javascrip whether it is enabled or disabled in browser, my site will not work properly for them. So, i want to prevent them from unknowingly feel that the site has problem. Instead i just want to throw an error like google or any site does. If an access to my page comes from a browser i should first check whether the javascript functionality has been enables or not. If not i will throw an error saying that "please enable javascript in your browser for the better user interface something like that. How can i acheive this. I am having this in mind but do not know how to acheive the output. Any help will be greatful. Thanks!
  8. Hi requinix, Thanks for the reply. But i want to know the way i can apply the method into my textarea. Since i m not that expert, i want your help in that. Just show me the javascript function which can be called to test it.. Thanks!
  9. Hi there, I am having the following ad posting page. But i m really confused of applying a input validation. I just want to display error when there is any field which left unfilled. Error should be displayed near the field. In case of email i want to show whether the email is already available in the database or not. if available i will show available. if not available then i will show the same. All the validations should happen when i click submit button. If everything is filled, then the submit button should take me to next page. Can anyone help me with this. I m terrible in search for it. my code: <?php include("conndb.php"); function createoptions($table , $id , $field) { $sql = "select * from $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Post a Free Ad</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> <style> #entrydt1 { margin-left: 100px; } #orderid1 { margin-left: 107px; } #orderdt1 { margin-left: 94px; } #itemid { margin-left: 142px; } #qtyid { margin-left: 122px; } #packid { margin-left: 120px; } #qtynoid { margin-left: 80px; } #Poid { margin-left: 80px; } #resetid { margin-left: 80px; } #clearid { margin-left: 80px; } #Name { margin-left: 50px; width: 100px; } </style> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#MRP").change(function(){ var qty = $('#subcat2').val(); var MRP = $('#MRP').val(); var t7 = $('#t7').val(); var total = (qty * (MRP*(t7/100))); $("#amount").val(total); }) }) $(function(){ $("select#category").change(function(){ $.getJSON("select.php",{category: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#subcategory").html(options); }) }) $("select#subcategory").change(function(){ $.getJSON("select.php",{subcategory: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; //options = '<input type="text" id="subcat2" name="subcat2" value="' + j[i].optionDisplay + '" />'; } /*$("select#subcategory2").html(options);*/ }) }) }) $(function(){ $("select#category").change(function(){ $.getJSON("select.php",{category: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#subcategory").html(options); }) }) $("select#subcategory").change(function(){ $.getJSON("select.php",{subcategory: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; //options = '<input type="text" id="subcat2" name="subcat2" value="' + j[i].optionDisplay + '" />'; } ("select#subcategory2").html(options); }) }) }) </script> </script> </head> <body> <h1>Post a Free Ad</h1> <form method="post" name="form" action="preview.php"> <table border='0'> <tr> <td><label for="name">Enter the name of the product or service you want</label></td> <td> <input type="text" name="ad" size=20 value=""/></td> </tr> <tr> <td> Select your Category</td> <td><select name="cat" id="category" style="width:11em;"> <option value="-1">--Select--</option> <?php createoptions("category", "cat_id", "category"); ?> </select> </td> </tr> <tr> <td> Select Subcategory </td> <td><select name="subcat" id="subcategory" style="width:11em;"> </select> </td> </tr> <tr> <td>Ad Type </td> <td><input type="radio" name="adtype" value="I Am Offering">I Am Offering <input type="radio" name="adtype" value="I Am Looking For">I Am Looking For </td> </tr> <tr> <td>Ad Title <font color="red">*</font></td> <td><input type="text" name="title" value="" style="width:15em;"></td> </tr> <tr> <td>Location<font color="red">*</font></td> <td><input type="text" name="location" value="" style="width:15em;"></td> </tr> <tr> <td>Addtional Details</td> <td><textarea name="info" rows="5" cols="50"></textarea></td> </tr> <tr> <td> <font face="arial" color="green" size="5"/> Verification Details here!! </td> </tr> <tr> <td>Email </td> <td><input type="text" name="email" value="" style="width:15em;" / > </td> </tr> <tr> <td>Mobile </td> <td><input type="text" name="mobile" value="" style="width:15em;" / > </td> </tr> <td> <input type="submit" name="submit" value="Preview Ur Ad"/></td> </tr> </table> <br /> <br /> </form> </body> </html>
  10. Dear all, I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that. I know it can be done with regular expressions. But i m not aware of how to do. Can some one help with that. Here is my script. <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <tr> <td valign="top" align="left">Description</td> <td valign="top">:</td> <td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td> </tr>
  11. Dear all, I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that. I know it can be done with regular expressions. But i m not aware of how to do. Can some one help with that. Here is my script. <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <tr> <td valign="top" align="left">Description</td> <td valign="top">:</td> <td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td> </tr>
  12. Hi all, I have attached a php script that contains the state and cities in each state in a array. I want to store them into mysql in such a way i bring them into my ajax based multi drop down. Please help me on storing this as i need have them into mysql. By doing manual storage it takes lot of time. I knew it is possible to send this array to mysql. but not sure how to do that. please need help in this.! Thanks! statecity.php
  13. Dear All, I have a scenario where i want to display database field's with values after selecting the id from combo. For eg: I am having a stock table with stcid as primary key. I have other fields in stock table such as itemname, qty,package,rate,disc,amount etc. What i m looking to do is, In a php form, i want to have a combo alone initially that has to be loaded with available stcid's from db. Based on the id that is selected i want to load the fields dynamically with values from db for that particular id. The point is, i want to show the table field with label and boxes only after i select the id. which means initially my php page will have only the combo box. How can i do this.. Any examples or methods to achieve this?? Thanks!
  14. Dear all, I m presently having a php page in which i have table contains data from sql for an item. And i m looking to have a button for a field of item, which when i click it should open an ajax window with details from another sql table. Basically the idea is i have a purchase order form i.e in my present window in php in which i will have a field i.e Against PO pending. the value for that field will basically the calculated value from another sql table. When i clikc a button in PO pending it should load me the Po Pending table details in ajax pop up were i m able to pick the Pending po value.. How could i accomplish that.. I m not having any background in Ajax. Can anyone give me an example similar to my need.. So, that i can use as base reference.!! Thanks!
  15. Hi 50r, Yes, presently i have a table with one row in which i fill the five fields and when i click add item i store them into database. What i look for is, whenever i insert an item i want to display it in the same page below my present table. No mater how many items i insert, all should be displayed and i should be able to scroll and see them..!
  16. Dear all, I am having the following php form, which has a table in that, i ill fill up the details and when i click Place order it will store the details into database. My query is that instead of place order it to add item, and for each time i click add item, the store data should be shown below the page where i am working inside a table serially. I mean basically displaying the rows in a grid.. Once it reaches the maximum screen size i should be able to scroll down to see all the items i have added. After all finished adding items i should then want to Place order which finally takes all my items into a single table value.. Any suggestion or idea how to start would be greatful. Thanks. <?php include("conndb.php"); function createoptions($table , $id , $field) { $sql = "select * from $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } // mysql_connect('localhost', 'root', ''); // mysql_select_db('inventorydb'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Place an Order</title> <script language="javascript src="code.js"> </script> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> <style> #entrydt1 { margin-left: 100px; } #orderid1 { margin-left: 107px; } #orderdt1 { margin-left: 94px; } #itemid { margin-left: 142px; } #qtyid { margin-left: 122px; } #packid { margin-left: 120px; } #qtynoid { margin-left: 80px; } #Poid { margin-left: 80px; } #resetid { margin-left: 80px; } #clearid { margin-left: 80px; } #Name { margin-left: 50px; width:100px;} </style> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#category").change(function(){ $.getJSON("select.php",{category: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#subcategory").html(options); }) }) $("select#subcategory").change(function(){ $.getJSON("select.php",{subcategory: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { // options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; options = '<input type="text" name="subcat2" value="' + j[i].optionDisplay + '" />'; } $("div#subcategory2").html(options); }) }) }) </script> <script>function calculate() { document.getElementById("t8").value = parseFloat(document.getElementById("subcat2").value) * (parseFloat(document.getElementById("MRP").value)*(parseFloat(document.getElementById("t7").value)/100)); } </script> </head> <body> <h1>Place an Order</h1> <form method="post"> <table border='1' > <tr> <td><label for="t1">Item</label></td> <td><label for="t2">Quantity</label></td> <td><label for="t2">Packing</label></td> <td><label for="t2">Quantity in NO's</label></td> <td><label for="t2">MRP/RATE</label></td> <td><label for="t2">Discount</label></td> <td><label for="t2">Amount</label></td> </tr> <tr> <td> <select name="cat" id="category"> <option value="-1">--Select--</option> <?php createoptions("category", "cat_id", "category"); ?> </select> </td> <td><input name="t3" id="t3" size="10" value=""></td> <td> <select name="subcat" id="subcategory"> </select> </td> <td> <!-- <select name="subcat2" id="subcategory2"> </select> <input type="text" name="subcat2" value="" id="subcategory2" /> --> <div id="subcategory2"> </div> </td> <td><select name="MRP" id="MRP"> <option value=""><--Select--></option> <?php $sql = "SELECT Mrprate FROM mrp"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['Mrprate'] . "' >" . $row['Mrprate'] . "</option>"; } ?></td> <td><input name="t7" id="t7" size="10" placeholder="40%" value=""></td> <td><input name="t8" id="t8" size="10" value="" onchange="calculate()"></td> </tr> <tr> <td><input type="submit" name="submit" value="Place Order"></td> <td><input type="submit" name="submit1" value="Reset"></td> </tr> </table> </form> </body> </html> <?php if (isset($_POST['submit'])) { include 'db.php'; $item=$_POST['cat'] ; $qty= $_POST['t3'] ; $pack= $_POST['subcat'] ; $qtyno= $_POST['subcat2'] ; $mrp= $_POST['MRP'] ; $dis= $_POST['t7'] ; $amt= $_POST['t8'] ; $query= mysql_query("INSERT INTO `po`(Item,Quantity,Packing, QuantityNO, MRP, Discount, Amount) VALUES ('$item','$qty','$pack','$qtyno','$mrp','$dis','$amt')"); if(!$query) { die('Query Failed with exception'.mysql_error()); } else{ echo"Thanks for the input"; } } ?>
  17. Hi there, Following is the code of mine where i want the textbox named t8 to be loaded based on the value of combo named 'subcat3' , textbox name 'MRP', and textbox named 't7'. The real formula is as applied in the form this.t8.value=this.t8.value*subcat3*MRP-(MRP*t8/100) i tried to apply the above formula but it doesnot load anything.!! Dont know what prob.. Can anyone help me!! Thanks <?php mysql_connect('localhost', 'root', ''); mysql_select_db('inventorydb'); ?> <?php require "config.php"; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Purchase Order Form</title> <meta name="GENERATOR" content="Arachnophilia 4.0"> <meta name="FORMATTER" content="Arachnophilia 4.0"> <SCRIPT language="javascript"> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='po.php?cat=' + val ; } function reload3(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; var val2=form.subcat.options[form.subcat.options.selectedIndex].value; self.location='po.php?cat=' + val + '&cat3=' + val2 ; } </script> </head> <body> <h1>Place an Order</h1> <?php ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT itemname,item_id FROM item order by itemname"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(isset($_GET['cat'])) { $cat=$_GET['cat']; // This line is added to take care if your global variable is off } if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT packingname,packing_id FROM packing where item_id=$cat order by packingname"); }else{$quer=mysql_query("SELECT DISTINCT packingname,packing_id FROM packing order by packingname"); } ////////// end of query for second subcategory drop down list box /////////////////////////// /////// for Third drop down list we will check if sub category is selected else we will display all the subcategory3///// if(isset($_GET['cat3'])) { $cat3=$_GET['cat3']; // This line is added to take care if your global variable is off } else { $cat3 = ""; } if(isset($cat3) and strlen($cat3) > 0){ $quer3=mysql_query("SELECT DISTINCT sizename FROM size where packing_id=$cat3 order by sizename"); }else{$quer3=mysql_query("SELECT DISTINCT sizename FROM size order by sizename"); } ////////// end of query for third subcategory drop down list box /////////////////////////// ?> <form method=post name=f1 action=''> <table border='1' > <tr> <td><label for="t1">Item</label></td> <td><label for="t2">Quantity</label></td> <td><label for="t2">Packing</label></td> <td><label for="t2">Quantity in NO</label></td> <td><label for="t2">MRP/RATE</label></td> <td><label for="t2">Discount</label></td> <td><label for="t2">Amount</label></td> </tr> <tr> <td> <?php ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['item_id']==@$cat){echo "<option selected value='$noticia2[item_id]'>$noticia2[itemname]</option>"."<BR>";} else{echo "<option value='$noticia2[item_id]'>$noticia2[itemname]</option>";} } echo "</select>"; ?> </td> <td><input name="t3" id="t3" size="10" value=""></td> <td> <?php ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat' onchange=\"reload3(this.form)\"><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { if($noticia['packing_id']==@$cat3){echo "<option selected value='$noticia[packing_id]'>$noticia[packingname]</option>"."<BR>";} else{echo "<option value='$noticia[packing_id]'>$noticia[packingname]</option>";} } echo "</select>"; ////////////////// This will end the second drop down list /////////// ?> </td> <td> <?php ////////// Starting of third drop downlist ///////// echo "<select name='subcat3' ><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer3)) { echo "<option value='$noticia[sizename]'>$noticia[sizename]</option>"; //echo "<input type='text' name='' value='$noticia[sizename]'/>"; } echo "</select>"; ////////////////// This will end the third drop down list /////////// ?> </td> <td><input name="MRP" id="t7" size="10" value=""></td> <td><input name="t7" id="t8" size="10" placeholder="40%" value=""></td> <td><input name="t8" id="t8" size="10" onchange="this.t8.value=this.t8.value*subcat3*MRP-(MRP*t8/100)" value=""></td> </tr> <tr> <td></td><td></td><td></td><td></td> <td><input type="submit" name="submit" value="Place Order"></td> <td><input type="reset" name="submit1" value="Reset"></td> <td></td> </tr> </body> </html> <?php if(isset($_POST['submit'])) { $item=$_POST['cat'] ; $qty= $_POST['t3'] ; $pack= $_POST['subcat'] ; $qtyno= $_POST['subcat3'] ; $mrp= $_POST['MRP'] ; $dis= $_POST['t7'] ; $amt= $_POST['t8'] ; $query= mysql_query("INSERT INTO `po`(Item,Quantity,Packing, QuantityNO, MRP, Discount, Amount) VALUES ('$item','$qty','$pack','$qtyno','$mrp','$dis','$amt')"); if(!$query) { die('Query Failed with exception'.mysql_error()); } } ?>
  18. It doesnt throw error, but rather it dint populate me the drop downs properly. for eg if the click an item from 1st dropdown, 2nd dropdown automatically loads all values rather than a value associated with the selected item.
  19. Hi there, I am having the following triple drop down page and the code does works very well. But one small change i need to make.. the following code does shows three drop downs from which i can perform the action. Instead i want the three drop down's to be displayed inside a table as three different coloums. when i tried with <td>.<tr> it thrown me error. Any suggestion on how to put them in place inside a table but without changing functionality. <?php require "config.php"; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Demo of Three Multiple drop down list box</title> <meta name="GENERATOR" content="Arachnophilia 4.0"> <meta name="FORMATTER" content="Arachnophilia 4.0"> <SCRIPT language=Javascript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='index.php?cat=' + val ; } function reload3(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; var val2=form.subcat.options[form.subcat.options.selectedIndex].value; self.location='index.php?cat=' + val + '&cat3=' + val2 ; } </script> </head> <body> <table border="1"> <?php ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT itemname,item_id FROM item order by itemname"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// $cat=$_GET['cat']; // This line is added to take care if your global variable is off if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT packingname,packing_id FROM packing where item_id=$cat order by packingname"); }else{$quer=mysql_query("SELECT DISTINCT packingname,packing_id FROM packing order by packingname"); } ////////// end of query for second subcategory drop down list box /////////////////////////// /////// for Third drop down list we will check if sub category is selected else we will display all the subcategory3///// $cat3=$_GET['cat3']; // This line is added to take care if your global variable is off if(isset($cat3) and strlen($cat3) > 0){ $quer3=mysql_query("SELECT DISTINCT sizename FROM size where packing_id=$cat3 order by sizename"); }else{$quer3=mysql_query("SELECT DISTINCT sizename FROM size order by sizename"); } ////////// end of query for third subcategory drop down list box /////////////////////////// echo "<form method=post name=f1 action='dd3ck.php'>"; ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['item_id']==@$cat){echo "<option selected value='$noticia2[item_id]'>$noticia2[itemname]</option>"."<BR>";} else{echo "<option value='$noticia2[item_id]'>$noticia2[itemname]</option>";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat' onchange=\"reload3(this.form)\"><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { if($noticia['packing_id']==@$cat3){echo "<option selected value='$noticia[packing_id]'>$noticia[packingname]</option>"."<BR>";} else{echo "<option value='$noticia[packing_id]'>$noticia[packingname]</option>";} } echo "</select>"; ////////////////// This will end the second drop down list /////////// ////////// Starting of third drop downlist ///////// echo "<select name='subcat3' ><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer3)) { echo "<option value='$noticia[sizename]'>$noticia[sizename]</option>"; //echo "<input type='text' name='' value='$noticia[sizename]'/>"; } echo "</select>"; ////////////////// This will end the third drop down list /////////// ?> </table> </body> </html>
  20. Dear all, Happy New Year, I am looking to have a method. But not sure how much it is possible to do with php. for eg. i have a php form with Itemname,id,packname,store location. All are text fields. And when i click the text field store location, i want to show a subwindow which consisting of details from my another table for store location which might have location id, name,reference and its values. I want to either select a location from list or add new dynamically in the subwindow. I need to know how much it is possible and how can i start with.. Any help is appreciated..! Thanks!!
  21. Dear all, I am actually trying to have triple dropdown in my php form. i.e 1st drop down initially loads with default values and once selecting a value in it, then second dropdown loads based on the value selected in 1st combo, following 3rd combo based on value selected in 2nd combo. I referred this example : http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html The problem is the Source code itself not working. when i run the source code with changes made as specified by the author, i am able to select the first combo with values usa,Canada. but second and third combo does not work.. My index file is <code><HTML> <HEAD> <TITLE>AJAX DEMO</TITLE> <script language="javascript" type="text/javascript"> function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getState(countryId) { alert(req.responseText); var strURL="findState.php?country="+countryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('statediv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } function getCity(countryId,stateId) { var strURL="findCity.php?country="+countryId+"&state="+stateId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) // only if "OK" { if (req.status == 200) { document.getElementById('citydiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> </HEAD> <BODY> <form method="post" name="form1"> <table border="0" cellpadding="0" cellspacing="0" width="60%"><tbody> <tr> <td width="150">Country</td> <td width="150"><select style="background-color: #ffffa0" name="country" onchange="getState(this.value)"><option>Select Country</option><option value="1">USA</option><option value="2">Canada</option> </select></td> </tr> <tr> <td>State</td> <td> <p id="statediv"> <select style="background-color: #ffffa0" name="state"><option>Select Country First</option> </select></td> </tr> <tr> <td>City</td> <td> <p id="citydiv"> <select style="background-color: #ffffa0" name="city"><option>Select State First</option> </select></td> </tr> </tbody></table> </form> </BODY> </HTML> </code> findCity.php: <code> <!--//---------------------------------+ // Developed by Roshan Bhattarai | // http://roshanbh.com.np | // Contact for custom scripts | // or implementation help. | // email-nepaliboy007@yahoo.com | //---------------------------------+--> <? #### Roshan's Ajax dropdown code with php #### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com #### if you have any problem contact me at http://roshanbh.com.np #### fell free to visit my blog http://php-ajax-guru.blogspot.com ?> <? $countryId=intval($_GET['country']); $stateId=intval($_GET['state']); $link = mysql_connect('localhost', 'root', ''); //changet the configuration in required if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('db_ajax'); $query="SELECT id,city FROM city WHERE countryid='$countryId' AND stateid='$stateId'"; $result=mysql_query($query); ?> <select name="city"> <option>Select City</option> <? while($row=mysql_fetch_array($result)) { ?> <option value><?=$row['city']?></option> <? } ?> </select> </code> findState.php: <code> <!--//---------------------------------+ // Developed by Roshan Bhattarai | // http://roshanbh.com.np | // Contact for custom scripts | // or implementation help. | // email-nepaliboy007@yahoo.com | //---------------------------------+--> <? #### Roshan's Ajax dropdown code with php #### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com #### if you have any problem contact me at http://roshanbh.com.np #### fell free to visit my blog http://roshanbh.com.np ?> <? $country=intval($_GET['country']); $link = mysql_connect('localhost', 'root', ''); //changet the configuration in required if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('db_ajax'); $query="SELECT id,statename FROM state WHERE countryid='$country'"; $result=mysql_query($query); ?> <select name="state" onchange="getCity(<?=$country?>,this.value)"> <option>Select State</option> <? while($row=mysql_fetch_array($result)) { ?> <option value=<?=$row['id']?>><?=$row['statename']?></option> <? } ?> </select> </code> Please let me know where the problem is!! or does this script requires any resource.! as a newbie i dont understand the problem exactly by looking at the code. Thanks!!
  22. Hi Sowna, The example link you have given is awesome. It is exactly similar to what i have been looking for, but only change is that i needed a text box instead of third combo box. Anyway, Can i get some sample code for such ajax call usage. Becuz i have not done that before. Since no idea on how to proceed further. If you provide me some example code, it will be great full. Thanks!!
  23. Dear Members, I have a doubt. I am having a table with three fields ItemName,Packing,Quantity. Each item has list of Packing's like Small,Medium,Large. And Each packing has size like 50,100,200. When i select ItemName from Combo1, My Combo2 Packing should be showing what all packs for that particualr item available and then show the size of that particular pack in textfield. In php form: ItemName: combo1 Packing: combo2 Quantity: textbox1 when combo1 selected values of combo2 must be changed based on combo1 selection. when combo2 has particular pack, textbox should display only quantity defined for that particular pack.. Can anyone suggest me how can proceed on this .. I knwo javascript is the only way. But i m not expert in it. referr me to some demo or example or piece of code from where i can get idea.. Thanks!
  24. Dear all, I am trying to load form data mysql table data into a combo box in php. for example i have a table called "item" and it has two fields name itemno, itemname. Each has values entered already. Now, in my form i want to have a combo box which holds the itemname field value from database table item. I tried with the below method. But it throws me this error "( ! ) Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\PO\index.php on line 63" Can anyone help me to resolve this!! <?php $sql="select itemno from item" $q=mysql_query($sql) echo "<select name=\"test\">"; echo "<option size =30 ></option>"; while($row = mysql_fetch_array($q)) { echo "<option value='".$row['itemno']."'>".$row['itemno']."</option>"; } echo "</select>"; ?>
  25. Dear members, Greetings, I am new bie to php and having a requirement to make a php form which will have fields and inputs arranged in a grid.. Example! Label1 Label2 Label3 Label4 textboxfor texboxfor textboxfor textboxfor label1 label2 label3 label4 button1 button2 How can i have such grid table in my form. i can develop a table and have rows and coloums but something like this i dont know. As well button1 and 2 for inserting data's into sql and retrieving!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.