I want to fetch data using ajax properly

shahol

New Member
I want to retrieve data from database using ajax the data is retrieving successfully but it is not showing properly on page. May be it is the issue of if else condition.Here is my code:\[code\]<?php $query = mysql_query("SELECT * FROM cart_polling WHERE country = '".$_REQUEST['id']."' ORDER BY sort_order ASC") or die(mysql_error()); $record = mysql_num_rows($query); while($getcontry = mysql_fetch_array($query)){ ?> <div class="Question_Table"> <div class="Question_Title">Q<?php echo $getcontry['sort_order']; ?>-<?php echo $getcontry['question']; ?></div><!-- ****** Box1 START ****** --> <?php if($getcontry['img1']!=""){ ?> <div class="bg"> <?php if(isset($_SESSION['id'])){ ?> <div class="img"><center> <a href="javascript:void(0)" class="op"><img src="http://stackoverflow.com/questions/14549333/images/pollimg/<?php echo $getcontry['img1']; ?>" width="104" height="102" class="middleimg2" onclick="getValue('<?php echo $_REQUEST['id']; ?>','<?php echo $getcontry['option1']; ?>','<?php echo $getcontry['id']; ?>','1','<?php echo $getcontry['img1'] ?>','<?php echo $getcontry['categoryname'] ?>','<?php echo $getcontry['question']; ?>')" /></a></center></div><?php } ?><div class="Vote_button"><img src="http://stackoverflow.com/questions/14549333/images/vote_button.png" onclick="sendvar();" align="middle"> <img src="http://stackoverflow.com/questions/14549333/images/view_results.png" onClick="showresult(<?php echo $getcontry['id']; ?>)" align="middle"></div><?php}</div><?php } ?> // here the while loops end.\[/code\]I want \[code\](<div id="txtHint<?php echo $getcontry['id']; ?>"></div>)\[/code\] this in else conditionand the above code in if condition when i click on image viewresut.png a function call which retrieve data from database. I want the data will show in else condition and the above code including loop shows in if condition. The txtHint($getcontray['id']) is the id of every record whose value changes dynamically with the help of while loop. And txthint is also saves the response of ajax. If i am using if condition than while loop is not running in else condition and the id can't pass to ajax response and the correct data will not show so please help me how can i do that.
 
Back
Top