Below is the index page: having these code: Data gets populated in a div as expected.
<h2>Search for users</h2> <input type="text" name="search" id="search" autocomplete="off" placeholder="Enter Customer ID here...."> <div id="output"></div> <script type="text/javascript"> $(document).ready(function(){ $("#search").keyup(function(){ var query = $(this).val(); if (query != "") { $.ajax({ url: 'ajax-db-search.php', method: 'POST', data: {query:query}, success: function(data){ $('#output').html(data); $('#output').css('display', 'block'); $("#search").focusin(function(){ $('#output').css('display', 'block'); }); } }); } else { $('#output').css('display', 'none'); } }); }); </script>
This is the ajax-db-search.php page. (In the IF tags I tried it with == and no good luck yet.)
<?php $conn=mysqli_connect("*****","*********","******","*****"); $query = "SELECT * FROM `create_customer` WHERE `Customer Id` LIKE '{$_POST['query']}%' LIMIT 6"; $result = mysqli_query($conn, $query); $plan = $query['Plan']; if ($plan = "planA") { while ($user = mysqli_fetch_array($result)) { echo "<h2>".$user['Customer Name']."</h2>"; echo "<h4><a href='http://smjw.phatake.in/admin/cc.php?recordID=".$user['id']."'>Update Profile Details</a></h4>"; echo "<h4><a href='http://smjw.phatake.in/admin/planA_details.php?recordID=".$user['Customer Id']."'>Receive Payment</a></h4>"; var_dump ($plan); } } if ($plan = "planB") { while ($user = mysqli_fetch_array($result)) { echo "<h2>".$user['Customer Name']."</h2>"; echo "<h4><a href='http://smjw.phatake.in/admin/cc.php?recordID=".$user['id']."'>Update Profile Details</a></h4>"; echo "<h4><a href='http://smjw.phatake.in/admin/planB_details.php?recordID=".$user['Customer Id']."'>Receive Payment</a></h4>"; } } if ($plan = "planC") { while ($user = mysqli_fetch_array($result)) { echo "<h2>".$user['Customer Name']."</h2>"; echo "<h4><a href='http://smjw.phatake.in/admin/cc.php?recordID=".$user['id']."'>Update Profile Details</a></h4>"; echo "<h4><a href='http://smjw.phatake.in/admin/planC_details.php?recordID=".$user['Customer Id']."'>Receive Payment</a></h4>"; } } if ($plan = "planA1") { while ($user = mysqli_fetch_array($result)) { echo "<h2>".$user['Customer Name']."</h2>"; echo "<h4><a href='http://smjw.phatake.in/admin/cc.php?recordID=".$user['id']."'>Update Profile Details</a></h4>"; echo "<h4><a href='http://smjw.phatake.in/admin/planA1_details.php?recordID=".$user['Customer Id']."'>Receive Payment</a></h4>"; } } else { echo "<p style='color:red'>User not found...</p>"; } ?>
The Problem is with the If condition: The Url's that needs to be displayed on my index page should change according to the $plan variable. But for some reason the $plan variable is always planA..
There are 4/5 Plans.. planA, planB, planc, planA1 each having different Urls that needs to displayed.
The URL do get populated but will be always the First IF conditions URL for all the customers.
Please help me out with this. Stuck for big time.
-------Update-------------
I want each of the Receive Payment to be according to the if conditions.. Now its all only planA
https://stackoverflow.com/questions/66791847/search-box-to-retrieve-data-using-ajax-and-php March 25, 2021 at 09:36AM
没有评论:
发表评论