adetkf Posted November 6, 2012 Share Posted November 6, 2012 Sorry 4 bad english First i have problem went i called back filter year(Tahun) and Angkatan(class) First i will choose student from Tahun(Year) and Angkatan(class) <html><head> <title> Halaman Pencarian </title> </head> <body> <form name="formcari" method="post" action="home4.php"> <table width="330" border="0" align="center" cellpadding="0"> <tr bgcolor="orange"> <td height="25" colspan="3"> <strong> Student Searching ! </strong> </td> </tr> <tr> <td>Tahun</td> <td><select name="thn"> <option>2012</option> <option>2013</option> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> <option>2021</option> <option>2022</option> <option>2023</option> </select></td> </tr> <tr> <td> Angkatan </td> <td> <input type="text" name="name"> </td> </tr> <td></td> <td> <input type="SUBMIT" name="SUBMIT" id="SUBMIT" value="search" > </td> </table> </form> </body> </html> This screenshoot after succes choose year and class student go to Home.php. <?php session_start(); include("connect.php"); if($_SESSION['user']=="") { header("location:index.php?err=must login first"); } ?> <style type="text/css"> .c { font:"Arial Black", Gadget, sans-serif ; color:#000; #pattern-style-a { font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size: 12px; margin: 45px; width: 480px; text-align: left; border-collapse: collapse; background: url('table-images/pattern.png'); } #pattern-style-a thead tr { background: url('table-images/pattern-head.png'); } #pattern-style-a th { font-size: 13px; font-weight: normal; padding: 8px; border-bottom: 1px solid #fff; color: #039; } #pattern-style-a td { padding: 8px; border-bottom: 1px solid #fff; color: #669; border-top: 1px solid transparent; } #pattern-style-a tbody tr:hover td { color: #339; background: #fff; } } </style> <html> <head></head> <body> <table width="100%" border="0"> <tr> <td height="58"><h1> welcome USER</h1></td> </tr> <tr> <td align="right"> <?php $uu=$_SESSION['user']; $b=time(); print date("D, d F Y",$ B); echo ("| Welcome $uu |")?> <a href="logout.php">Logout </a></td> </tr> <tr> <td align="center"></td> </tr> <tr> <td><span class="c"><strong>Nilai Corporate Exposure ICT </strong></span> </td> </tr> <tr> <td> <table width="100%" border="1" cellpadding="0" cellspacing="0" id="pattern-style-a"> <thead> <tr> <th rowspan="2" scope="col">No</th> <th rowspan="2" scope="col">NIP</th> <th width="17%" rowspan="2" scope="col">Nama</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> <th scope="col">�</th> </tr> <tr> <th scope="col">Nilai A</th> <th scope="col">Input Nilai A</th> <th scope="col"> Nilai B</th> <th scope="col">Input Nilai B</th> <th scope="col">Nilai C</th> <th scope="col">Input Nilai C</th> <th scope="col">Nilai D</th> <th scope="col">Input Nilai D</th> <th scope="col">Nilai E</th> <th scope="col">Input Nilai E</th> <th scope="col">Nilai F</th> <th scope="col">Input Nilai F</th> <th scope="col"> Nilai G</th> <th scope="col">Input Nilai G</th> </tr> </thead> <tr> <?php $name= $_POST['name']; $thn= $_POST['thn']; $query="SELECT * from msnama where angkatan like '%$name%' and tahun like '%$thn%' "; $rs=mysql_query($query); $_SESSION['angkatan']=$name; $_SESSION['admin_access'] = $thn; while($row=mysql_fetch_array($rs)) { ?> <td align="center"><?php echo $row[0]; ?></td> <td align="center"><?php echo $row[2]; ?></td> <td align="center"><?php echo $row[3]; ?></td> <td align="center"><?php echo $row[11]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT1.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" > <input type="submit" name="button" id="button" value="Submit"> </form></td> <td align="center"><?php echo $row[10]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT2.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" min="0" max="100" > <input type="submit" name="button" id="button" value="Submit"> </form></td> <td align="center"><?php echo $row[11]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT3.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" min="0" max="100" > <input type="submit" name="button" id="button" value="Submit"> </form></td> <td align="center"><?php echo $row[12]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT4.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" min="0" max="100" > <input type="submit" name="button" id="button" value="Submit"> </form></td> <td align="center"><?php echo $row[13]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT5.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" min="0" max="100" > <input type="submit" name="button" id="button" value="Submit"> </form></td> <td align="center"><?php echo $row[14]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT6.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" min="0" max="100" > <input type="submit" name="button" id="button" value="Submit"> </form></td> <td align="center"><?php echo $row[15]; ?></td> <td align="center"><form name="form1" method="post" action="doupdateICT7.php?id=<?php echo $row[0];?>"> <label for="textfield"></label> <input type="text" name="qty" id="textfield" size="4" min="0" max="100" > <input type="submit" name="button" id="button" value="Submit"> </form></td> </tr> <?php } ?> </table> </td> </tr> <tr> <td><?php if (!empty($_GET['error'])) { if ($_GET['error'] == 2) { echo '<h3>Berhasil Input</h3>';} } ?></td> </tr> <tr> <td>�</td> </tr> <tr class="c"> <td class="c">�</td> </tr> <tr> <td></td> </tr> </table> <p>�</p> <p>�</p> </body> </html> picture or screenshot because me choose class 1 so will be show only nilai(grade) from class 1[spoiler=ss] then i'm input 100 for alfa.. This code doupdateICT1.php <?phpinclude "Connect.php"; session_start(); $id=$_REQUEST['id']; $qty=$_REQUEST['qty']; mysql_query("update msNama set Nilai_ICT='".$qty."' where ID_nama='$id' "); header("location:home4.php?error==2&id;=$id&qty;=$qty"); ?> grade 100 succes to input and it back to page home4. this problem why all table class showed. not class 1 like me choose first. this sceenshot Sorry 4 bad grammar Link to comment https://forums.phpfreaks.com/topic/270350-askabout-searchingfilter-and-inputupdate/ Share on other sites More sharing options...
Muddy_Funster Posted November 6, 2012 Share Posted November 6, 2012 I don't think you can post attached files untill you get a minnimum post count. Anyway, your problem is here : $name= $_POST['name']; $thn= $_POST['thn']; $query="SELECT * from msnama where angkatan like '%$name%' and tahun like '%$thn%' "; when you return to the page there are no post variables set, so the query is not being filtered. Here's a quick fix : if(isset($_POST['name'])){ $_SESSION['name'] = $_POST['name']; } $name= $_SESSION['name']; if(isset($_POST['thn'])){ $_SESSION['thn'] = $_POST['thn']; } $thn= $_SESSION['thn']; $query="SELECT * from msnama where angkatan like '%$name%' and tahun like '%$thn%' "; Some other things you need to look at : NOT using SELECT * Data Input Sanitization Link to comment https://forums.phpfreaks.com/topic/270350-askabout-searchingfilter-and-inputupdate/#findComment-1390489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.