I'm trying to populate mysql table inside ul li tags. I couldn't be success. I don't know how to use jquery to get mysql data. Can you guys help me please? I'm getting my result on getdata.php without any problem. However I couldn't success to show result inside main.php without refreshing page.
main.php
<form name="cnt" id="cnt" action="get_shipping_price.php" method="Post" >
<select id="c_list" name="country" style="width:160px;" onChange="this.form.submit()">
<?php
$countries = $database->getCountry();
foreach ($countries as $country) {
echo '<option value="' . $country['printable_name'] . '" ' . ($req_user_info['country'] == $country['numcode'] ? 'selected="selected"' : '') . '>' . $country['printable_name'] . '</option>';
}
?>
</select>
</form>
<!-- result list box -->
<div id="result_box">
<ul>
<li class="blue_heading">A</li>
<li class="blue_heading">O / E</li>
<li class="blue_heading">I / I</li>
<li class="lgray_lis"></li>
<li class="lgray_lis"></li>
<li class="lgray_lis"></li>
<li class="dgray_lis"></li>
<li class="dgray_lis"></li>
<li class="dgray_lis"></li>
</ul>
</div>
get_data.php
<?php
include("include/database.php");
if(isset($_POST['country']) )
{
$cnt_id = $_POST['country'];
$result = $database->select("Select * From zone Where DHL = '$cnt_id' ");
foreach ($result as $row) {
$row['zone'];
}
}
$result = $database->select("Select * From price_in_dis");
foreach ($result as $indis)
{
if ($row['zone'] == 1)
{
echo "<ul>";
echo "<li>" .'y'.$indis['A']. "</li>";
echo "</ul>";
}
if ($row['zone'] == 2)
{
echo "<ul>";
echo "<li>" .$dis['C']. "</li>" ;
echo "</ul>";
}
if ($row['zone'] == 3)
{
echo "<ul>";
echo "<li>" .$dis['D']. "</li>" ;
echo "</ul>";
}
}
?>
I see 3 options,
Use a form or something to submit the value.
Make the Li clickable with with link where you pass through the variable value.
Use Ajax and Jquery to make some functions on 'click submit this'. There is a lot of different ways to do this, you can create a hidden form for example. ( I recommended this one only if you add some security in both sides, client and server)
U'll need a php file anyway the different is how you pass the parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.