php - collapse function based the number of data, increment html? -
currently display data database condition write in query got 6 data display
select * vacancy_db, company_db vacancy_db.company_id = company_db.company_id , vacancy_db.isactive = 1 order vacancy_db.vacancy_id
but want create collapse function display 6 data. current code (all code)
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "company_mandiri_db"; //connection $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die("connection failed: " . mysqli_connect_error()); } $sql = "select * vacancy_db, company_db vacancy_db.company_id = company_db.company_id , vacancy_db.isactive = 1 order vacancy_db.vacancy_id "; $sql2 = "select vacancy_id,vacancy_responsible vacancy_db_job_respon"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result) ) { if ($row["vacancy_id"]%2==0) { echo "<div class='container-fluid' id='container-job'>"; } else { echo "<div class='bg-grey container-fluid' id='container-job'>"; } echo " <div class='container'>"; echo " <h2>simple collapsible</h2>"; echo " <button type='button' class='btn btn-lg btn-info collapsed' data-toggle='collapse' data-target='#demo'>simple collapsible</button>"; echo " <div id='demo' class='collapse'>"; //logo echo "<div class='row' >"; echo "<div class ='col-md-2 company-logo' >"; echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['company_logo'] ).'"/>'; echo "</div>"; //middle-column echo "<div class ='col-md-8 ' >"; echo "<div class = 'vacancy_title'>"; echo "<a href='job-page-view.php'>". $row['vacancy_title']. "</a>"; echo "</div>"; echo "<div class='company-name'>"; echo "<span class='text' id='company_name'>". $row['company_name']."</span>"; echo "</div>"; echo "<div class='vacancy-city'>"; echo "<span class='glyphicon glyphicon-map-marker'></span> "; echo "<span class='text' id='vacancy-city'>".$row['company_city'] ."</span>"; echo "</div>"; echo "<div class='vacancy-salary'>"; echo "<span class='text' id='vacancy-salary'>rp. " .$row['vacancy_salary'] ."</span>"; echo "</div>"; echo "<div class='vacancy-respon'>"; echo "<p>job responsible : </p>"; $result2 = mysqli_query($conn, $sql2); while($row2 = mysqli_fetch_assoc($result2)) { if ($row2["vacancy_id"]==$row["vacancy_id"]) { echo "<span class='glyphicon glyphicon-ok'></span> "; echo "<span class='text'>" .$row2['vacancy_responsible'] ."</span>"; echo "<br>"; } } echo "</div>"; //end echo "<div class ='col-md-8 ' >"; echo "</div>"; echo "<div class ='col-md-2 company-logo' >"; echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['company_logo'] ).'"/>'; echo "</div>"; //end row; echo "</div>"; //end collapse echo "</div>"; //end container collapse echo "</div>"; //end container-job echo "</div>"; } } else { echo "0 results"; } mysqli_close($conn); ?>
this code collapse button
echo " <div class='container'>"; echo " <h2>simple collapsible</h2>"; echo " <button type='button' class='btn btn-lg btn-info collapsed' data-toggle='collapse' data-target='#demo'>simple collapsible</button>"; echo " <div id='demo' class='collapse'>";
this content of data want display
//logo echo "<div class='row' >"; echo "<div class ='col-md-2 company-logo' >"; echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['company_logo'] ).'"/>'; echo "</div>"; //middle-column echo "<div class ='col-md-8 ' >"; echo "<div class = 'vacancy_title'>"; echo "<a href='job-page-view.php'>". $row['vacancy_title']. "</a>"; echo "</div>"; echo "<div class='company-name'>"; echo "<span class='text' id='company_name'>". $row['company_name']."</span>"; echo "</div>"; echo "<div class='vacancy-city'>"; echo "<span class='glyphicon glyphicon-map-marker'></span> "; echo "<span class='text' id='vacancy-city'>".$row['company_city'] ."</span>"; echo "</div>"; echo "<div class='vacancy-salary'>"; echo "<span class='text' id='vacancy-salary'>rp. " .$row['vacancy_salary'] ."</span>"; echo "</div>"; echo "<div class='vacancy-respon'>"; echo "<p>job responsible : </p>"; $result2 = mysqli_query($conn, $sql2); while($row2 = mysqli_fetch_assoc($result2)) { if ($row2["vacancy_id"]==$row["vacancy_id"]) { echo "<span class='glyphicon glyphicon-ok'></span> "; echo "<span class='text'>" .$row2['vacancy_responsible'] ."</span>"; echo "<br>"; } } echo "</div>"; //end echo "<div class ='col-md-8 ' >"; echo "</div>"; echo "<div class ='col-md-2 company-logo' >"; echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['company_logo'] ).'"/>'; echo "</div>"; //end row; echo "</div>"; //end collapse echo "</div>"; //end container collapse echo "</div>"; //end container-job echo "</div>"; }
as can see code display id "demo"
if create that. content hide , button display 6 times. when click button. show content number one. click button no2 or 3 etc
what want when click button no 1. must show content of number 1. if click button no 2. content no 2 active / show.
the sollution can think make data-target increment 1 based how many data. cant find how increment data-target
do know how increment data target? example data-target="#demo" + 1
Comments
Post a Comment