我正在尝试显示一个图形栏,以便在wordpress网站中使用MySql和PHP显示单个栏中特定日期的总座位数。
我的表格标记:
<strong>Check your desired date if it is available already in the system.</strong><br/><br/>
<form action="<?php echo get_permalink();?>" method="post" class="van_sharing_reference">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.search_input_text_van').datepicker({
dateFormat : 'yy-mm-dd'
});
});
</script>
<input type="text" placeholder="Select the date" required name="search_text" class="search_input_text_van">
<span class="arrow">
<input type="submit" value="CHECK" name="search" class="search_button">
</span>
</form>
和行动:
<?PHP
if (isset($_POST['search'])){
$serch_text = $_POST["search_text"];
$con=mysqli_connect("localhost","db_name","db_username","db_password");
// Check connection
if (mysqli_connect_errno()) {
die ("Failed to connect to MySQL: " . mysqli_connect_error());
}
$booking_id_serch_text = $serch_text;
$searchroute = "select * from van_sharing where date = '$booking_id_serch_text'";
$result = $con->query($searchroute);
$row = $result->fetch_assoc();
if ($row == 0) { echo '<div style="color: red;">No one planned yet on the date <b>' . $serch_text . '</b>. to go</div>' ;
} else {
// getting number of rows for a specific date
$wpdb->get_results( $wpdb->prepare('select * from van_sharing where date = %s', $booking_id_serch_text));
$total_seats = 10;
$people_travel_on_the_date = $wpdb->num_rows;
$available_seats = $total_seats - $people_travel_on_the_date;
echo 'Total Seats ' . $total_seats . '<br/>';
echo 'Number of people who are planning to share on the date '.$booking_id_serch_text .' : '.$wpdb->num_rows;
echo '</br>Available seats : '.$available_seats;
mysqli_close($con);
}
}
?>
现在,我正在向访问者展示我想要展示的所有细节。
但是我想在一个图形栏中显示这些内容,而不仅仅是在某些行中显示。 像:
我用谷歌搜索并引用了php.net但是所有的PHP drwaing即将创建图表,整个图表就像饼图或条形图,但不会在图形栏中显示这些结果。
如何使用php创建一个条形码? 它是一个wordpress网站。因此,通过自定义PHP更好,但不使用库。 我也不愿意使用插件。