cara menampilkan data ketika data A kosong yang tanpil data B dan sebaliknya

data

 <?php
 include_once '../connection.php';
     include("security.php");
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <!-- META SECTION -->
        <title>TITLE</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />

        <link rel="icon" href="favicon.ico" type="image/x-icon" />
        <!-- END META SECTION -->

        <!-- CSS INCLUDE -->
        <link rel="stylesheet" type="text/css" id="theme" href="css/theme-default.css"/>

   <link rel="stylesheet" type="text/css" href="../assets/js/jquery-ui/jquery-ui.css">


        <!-- EOF CSS INCLUDE -->

        <style type="text/css">
            .foo {
  float: left;
  width: 20px;
  height: 20px;
  margin: 1px;
  border: 1px solid rgba(0, 0, 0, .2);
}

.white {
  background: #fdfbfb;
}

.red {
  background: #fd343d;
}

.yellow {
  background: #e9fb6c;
}
        </style>
    </head>
    <body>


            <!-- PAGE CONTENT -->
            <div class="page-content">



                <!-- START BREADCRUMB -->
                <ul class="breadcrumb">
                    <li><a href="#">Link</a></li>
                    <li class="active">Active</li>
                </ul>
                <br><br><br><br>
                <!-- END BREADCRUMB -->


                <!-- PAGE CONTENT WRAPPER -->
                <div class="page-content-wrap">

                    <div class="row">
                        <div class="col-md-12">

                                <!-- START DEFAULT DATATABLE -->
                            <div class="panel panel-default">

                              <div class="panel-heading">
                                <h3 class="panel-title">Data Spareparts</h3>
                                  <ul class="panel-controls">
                                    <li><a href="homepage.php" class="fa"><img src="img/icons/fwd.png" width="15" height="15"></span></a></li>
<li><a href="#" class="panel-refresh"><span class="fa"><img src="img/icons/printer.png" width="15" height="15"></span></a></li>
                                      <li><a href="#" class="panel-refresh"><span class="fa"><img src="img/icons/xls.png" width="15" height="15"></span></a></li>
                                       <li><a href="#" class="panel-refresh"><span class="fa"><img src="img/icons/pdf.png" width="15" height="15"></span></a></li>
                                      <li><a href="#" class="panel-refresh"><span class="fa"><img src="img/icons/lk.png" width="15" height="15"></span></a></li>
                                      <li><a href="#" class="panel-collapse"><span class="fa"><img src="img/icons/dp.png" width="20" height="20"></span></a></li>
                                      <li><a href="#" class="panel-remove"><span class="fa fa-times"></span></a></li>
                                  </ul>


                                </div>

                                 <?php
                                      echo '<div class="panel-body">';
                                        $result1 = mysql_query("SELECT * from stock_in");



                                            echo '<table class="table datatable">';
                                            echo '<thead>';
                                            echo '<tr>';
                                            echo '<th width="5%">No</th>';
                                            echo '<th width="10%">ITEM CODE</th>';
                                            echo '<th width="43%">DESCRIPTIONS</th>';
                                            echo '<th width="6%">SAP</th> ';
											echo '<th width="6%">ACT</th> ';
											echo '<th width="6%">DEF</th> ';
											echo '<th width="6%">UOM</th> ';
                                            echo '<th width="10%">LOCT</th> ';
                                            echo '<th>OPT</th> ';
                                            echo '</tr>';
                                            echo '</thead>';
                                            echo '<tbody>';
                                            while($row = mysql_fetch_array($result1)){
                                            echo '<tr>';
                                             $beg = ''.$row["id"] .'';

                                            echo "<td >" . $row["id"] . "</td>";
                                            echo "<td>" . $row["stockno"] . "</td>";
                                            echo "<td>" . $row["item_name"] . "</td>";
                                            echo "<td>" . $row["sap"] . "</td>";
											echo "<td>" . $row["act"] . "</td>";
                                            echo "<td>" . $row["deff"] . "</td>";
											echo "<td>" . $row["unit"] . "</td>";
											echo "<td>" . $row["date"] . "</td>";
										echo "<td><a href='#myModal'id='custId' data-toggle='modal' data-id=".$row['id']."><img src='img/icons/txt.png' width='20' height='20'></a>



											</td>";


                                            echo'</tr>';
                                            }
                                  echo'</tbody>';
                                echo'</table>';
                              echo'</div>';
                            echo'</div>';
                            ?>
                            <!-- END DEFAULT DATATABLE -->

                        </div>
                    </div>

                </div>
                <!-- END PAGE CONTENT WRAPPER -->
            </div>
            <!-- END PAGE CONTENT -->

        <!-- MESSAGE BOX-->
        <div class="message-box animated fadeIn" data-sound="alert" id="mb-signout">
            <div class="mb-container">
                <div class="mb-middle">
                    <div class="mb-title"><span class="fa fa-sign-out"></span> Log <strong>Out</strong> ?</div>
                    <div class="mb-content">
                        <p>Are you sure you want to log out?</p>
                        <p>Press No if youwant to continue work. Press Yes to logout current user.</p>
                    </div>
                    <div class="mb-footer">
                        <div class="pull-right">
                            <a href="pages-login.html" class="btn btn-success btn-lg">Yes</a>
                            <button class="btn btn-default btn-lg mb-control-close">No</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- END MESSAGE BOX-->



        <!-- START POPUP MODAL DETAIL ITEM-->
         <div id="myModal" class="modal fade" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <h4 class="modal-title">Detail Barang</h4>
                </div>
                <div class="modal-body">
                    <div class="fetched-data"></div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Keluar</button>
                </div>
            </div>
        </div>
    </div>

                             <!-- END POPUP MODAL DETAIL ITEM-->











        <!-- START PRELOADS -->
        <audio id="audio-alert" src="audio/alert.mp3" preload="auto"></audio>
        <audio id="audio-fail" src="audio/fail.mp3" preload="auto"></audio>
        <!-- END PRELOADS -->

    <!-- START SCRIPTS -->
        <!-- START PLUGINS -->
        <script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery/jquery-ui.min.js"></script>
        <script type="text/javascript" src="js/plugins/bootstrap/bootstrap.min.js"></script>

        <script type="text/javascript" src="../assets/js/jquery-ui/jquery-ui.js"></script>

        <!-- END PLUGINS -->

            <!-- THIS PAGE PLUGINS -->
        <script type='text/javascript' src='js/plugins/icheck/icheck.min.js'></script>
        <script type="text/javascript" src="js/plugins/mcustomscrollbar/jquery.mCustomScrollbar.min.js"></script>

        <script type="text/javascript" src="js/plugins/datatables/jquery.dataTables.min.js"></script>
        <!-- END PAGE PLUGINS -->

        <!-- START TEMPLATE -->
        <script type="text/javascript" src="js/plugins.js"></script>
        <script type="text/javascript" src="js/actions.js"></script>


        <!-- END TEMPLATE -->
    <!-- END SCRIPTS -->


       <!-- start date -->
       <script type="text/javascript">
		$(document).ready(function(){
			$("#tgl").datepicker({dateFormat : 'yy/mm/dd'});
		});
	</script>
     <!-- end date -->


     <!-- pop up detail -->
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  <script type="text/javascript">
    $(document).ready(function(){
        $('#myModal').on('show.bs.modal', function (e) {
            var rowid = $(e.relatedTarget).data('id');
            //menggunakan fungsi ajax untuk pengambilan data
            $.ajax({
                type : 'post',
                url : 'sp_drawing.php',
                data :  'rowid='+ rowid,
                success : function(data){
                $('.fetched-data').html(data);//menampilkan data ke dalam modal
                }
            });
         });
    });
  </script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <!-- pop up detail -->



     <!-- END SCRIPTS -->
    </body>
</html>


detail data

 <?php
 include_once '../connection.php';

    if($_POST['rowid'])
        $id = $_POST['rowid'];
        $sql=mysql_query('select * from stock_in where id = "'.$id.'" ')or die(mysql_error());
        while($data=mysql_fetch_array($sql)){
		$id = ''.($data['id']). '';
		$link = ''.($data['link']). '';
		$foto = ''.($data['foto']). '';
        $link_Internet = $data['link']; //sesuaikan nama field
        $link_Lokal    = $data['foto']; //sesuaikan nama field
		$base_url = ""; //ini url project kamu apa ??
					    // jgn lupa nambahin folder tempat nyimpan gambar =>  "images/"
        $link_Lokal = $base_url . "images/" . $link_Lokal;
					  // cek jika $link_internet kosong maka yg ditampilkan $link_lokal dan sebaliknya..
		}

		?>

<div class="col-md-12 tbl-content">
  <form class="form-horizontal" role="form" action="pc_ed2.php" method="POST" enctype="multipart/form-data">
  <div class="tumpukan">
  <table class="table">
  <tr>
  <th><h3><span class="glyphicon glyphicon-book"></span>..!!</h3></th>
  </tr>

			<tr>
		    <td></td>
  <td><input type="hidden" name="id" value="<?php echo ''.$id.''; ?>" /></td>
			</tr>



            <tr>
            <th>BOOK DRAWING</th>
 <a class="pinterest" href="<?php echo empty($link_Internet) ? $link_Lokal : $link_Internet ?>"><span>ok</span></a></th>
			</tr>

             </div>

</form>
</div>




avatar maulanamahdi
@maulanamahdi

109 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

5 Jawaban:

bisa de perjelas apa yg dimaksud agan @maulanamahdi ? mungkin bisa disertakan tampilan webnya atau apanya gtu ?

avatar sila
@sila

15 Kontribusi 1 Poin

Dipost 6 tahun yang lalu

gini gan di tb stock in ada dua kolom foto (gambar yg ada di folder root) dan link (mengambil gambar di internet) jadi ketika tombol detail di klick keluar gambar di popup, ,jika gambar di kolom foto (gambar yg ada di folder root) empty yang tampil gambar yg di kolom link (mengambil gambar di internet) dan sebaliknyaa...tampilnya secara langsung di popup ga ada bantuan tombol lgi untu menampilkan gambar nya contoh di bawang menggunakan tombol bantu lagi dalam bentukk kertas

avatar maulanamahdi
@maulanamahdi

109 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

if else saja

avatar codingforbabies
@codingforbabies

159 Kontribusi 53 Poin

Dipost 6 tahun yang lalu

udah gan cuman gk bisa tampil langsung di popupnya

 <?php
 include_once '../connection.php';

    if($_POST['rowid'])
        $id = $_POST['rowid'];
        $sql=mysql_query('select * from stock_in where id = "'.$id.'" ')or die(mysql_error());
        while($data=mysql_fetch_array($sql)){
		$id = ''.($data['id']). '';
		$link = ''.($data['link']). '';
		$foto = ''.($data['foto']). '';
        $link_Internet = $data['link']; //sesuaikan nama field
        $link_Lokal    = $data['foto']; //sesuaikan nama field
		$base_url = ""; //ini url project kamu apa ??
					    // jgn lupa nambahin folder tempat nyimpan gambar =>  "images/"
        $link_Lokal = $base_url . "images/" . $link_Lokal;
					  // cek jika $link_internet kosong maka yg ditampilkan $link_lokal dan sebaliknya..
		}

		?>

<div class="col-md-12 tbl-content">
  <form class="form-horizontal" role="form" action="pc_ed2.php" method="POST" enctype="multipart/form-data">
  <div class="tumpukan">
  <table class="table">
  <tr>
  <th><h3><span class="glyphicon glyphicon-book"></span>..!!</h3></th>
  </tr>

			<tr>
		    <td></td>
  <td><input type="hidden" name="id" value="<?php echo ''.$id.''; ?>" /></td>
			</tr>



            <tr>
            <th>BOOK DRAWING</th>
 <a class="pinterest" href="<?php echo empty($link_Internet) ? $link_Lokal : $link_Internet ?>"><span>ok</span></a></th>
			</tr>

             </div>

</form>
</div>
avatar maulanamahdi
@maulanamahdi

109 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

![](<?php echo'$data[foto]'?>) isiin di dalem modal atau pop upnya

coba cari di sini contoh modal https://getbootstrap.com/docs/4.1/components/modal/

avatar sila
@sila

15 Kontribusi 1 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban