jquery - How to use <select> element in php for navigating database? -
i've made html page this. users can select dropdown list, whether want download hall ticket or result. not able link options in tag database. please me php code.
<html> <body> <table width="200" border="0" class="download"> <form name="download" action="downloadhalltickets.php" method="post"> <caption align="top"> downloads: </caption> <tr> <td>select:</td> <td> <select name="select"> <option value="hall tickets">hall tickets</option> <option value="results">results</option> </select> </td> </tr> <tr> <td>seat no.</td> <td><input type="text" name="seatno" maxlength="10" /> </td> </tr> <tr> <td><input type="submit" name="download1" value="download" /></td> </tr> </form> </table> </body> </html>
now want select 1 between following 2 php pages on select option above html page..
downloadhalltickets.php
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link href="downloadhalltickets.css" type="text/css" rel="stylesheet"/> <title>download halltickets</title> </head> <body> <?php $host="localhost"; // host name $username="mt_prakash"; // mysql username $password="h.patil"; // mysql password $db_name="mt_test"; // database name $tbl_name="members"; // table name // connect server , select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); ?> <?php $select = $_post['select']; $seatno = $_post['seatno']; if ($select=='hall tickets'){ $query1 ="select * hallticket seatno='$seatno'"; $query2= mysql_query($query1); while ($row1 = mysql_fetch_array($query2)) { ?> <input type="button" value=" print page " onclick="window.print();return false;" style="border-bottom-style:double;background-color:#ff6600;" align="right"/> <form name="hallticket" id="hallticket" method="post" action=""> <table width="763" id="hallticket1" border="1"> <tr> <td colspan="4" align="center" style="color:#3300ff"><h1>maharashtra tantra niketan shikshan mandal</h1> <h3>(established under govt. of maharashtra pt act)</h3> <br /> <span style="padding:3px 5px; background-color:#3366ff; border-radius:10px; color:#ffffff">hall ticket</span> <p></p></td> </tr> <tr> <td width="37"> </td> <td width="170">name:</td> <td width="373"><?php echo $row1['name']; ?></td> <td width="165" rowspan="3"><img src="" alt="photo" name="photo" width="86" height="92" id="photo" style="background-color: #ffffff" /></td> </tr> <tr> <td> </td> <td>exam date: </td> <td><?php echo $row1['examdate']; ?></td> </tr> <tr> <td> </td> <td>exam time: </td> <td><?php echo $row1['examtime']; ?></td> </tr> <tr> <td> </td> <td>exam center: </td> <td><?php echo $row1['examcenter']; ?></td> <td> </td> </tr> <tr> <td> </td> <td>seat no: </td> <td><?php echo $row1['seatno']; ?></td> <td><img src="" alt="signature" name="signature" width="87" height="32" id="photo" style="background-color: #ffffff" /></td> </tr> </table> </form> <?php } } ?> </body> </html>
downloadresults.php
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>download results</title> <link href="downloadhalltickets.css" type="text/css" rel="stylesheet"/> </head> <body> <?php $host="localhost"; // host name $username="mt_prakash"; // mysql username $password="h.patil"; // mysql password $db_name="mt_test"; // database name $tbl_name="members"; // table name // connect server , select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); $select = $_post['select']; $seatno = $_post['seatno']; if ($select=='results'){ $query1 ="select * result resultseatno='$seatno'"; $query2= mysql_query($query1); while ($row1 = mysql_fetch_array($query2)) { ?> <table width="806" cellpadding="10" class="upload" border="1" style="border-radius:0; background-color:#ffffff; border-collapse:collapse;"> <form action="upload.php" method="post" > <caption align="top"> result upload </caption> <tr> <td height="62" colspan="4" align="center"><h2 style=""><img src="mtnsm.jpg" width="84" height="103" style="float:left; clear:left"/>maharashtra tantra niketan shikshan mandal</h2> <p style="float:left" align="center"> </p> <h3 style="">*online result</h3></td> </tr> <tr> <td width="260"> name of student: </td> <td colspan="3"><?php echo $row1['resultname']; ?></td> </tr> <tr> <td>examination held in: </td> <td colspan="3"><?php echo $row1['resultlocation']; ?></td> </tr> <tr> <td>institute code : </td> <td colspan="2"><?php echo $row1['resultinstitute']; ?></td> <td width="327"> seat no: <?php echo $row1['resultseatno']; ?></td> </tr> <tr> <td>name of subject: </td> <td width="267">maximum marks </td> <td width="302">obtained marks </td> <td>grade</td> </tr> <tr> <td>talent search exam </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><p>a1 - 91 100</p> <p>a+ - 81 90</p> <p>a - 71 80</p> <p>b+ - 61 70</p> <p>b - 51 60</p> <p>c+ - 41 50</p> <p>c - 1 40</p></td> <td colspan="3"> </td> </tr> <tr> <td>date of result: </td> <td colspan="3"><?php echo $row1['resultdate']; ?></td> </tr> <tr> <td> </td> <td colspan="3" align="right"> </td> </tr> </form> </table> <?php } } ?> </body> </html>
i'm updating first html code here.... giving warning.. warning: cannot modify header information - headers sent (output started @ /home/mtnsmin/public_html/updates centers.php:8) in /home/mtnsmin/public_html/updates centers.php on line 27
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <link href="updates centers.css" type="text/css" rel="stylesheet"/> <link rel="icon" href="logo.jpg" type="image/x-icon"> <title>updates centers</title> <?php // connect server , select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); if($_post[select] == 'hall tickets'){ header('location: downloadhalltickets.php'); } elseif($_post[select] == 'results'){ header('location: downloadresults.php'); } ?> </head> <body> <div class="wrapper"><span style="opacity:1"><marquee behavior="alternate" scrollamount="5">welcome maharashtra tantra niketan shikshan sansthan</marquee></span> </div> <div id="tabse"> <ul> <!-- css tabs --> <li><a href="home.php"><span>home</span></a></li> <li><a href="services.php"><span>services</span></a></li> <li><a href="updates.php"><span>updates</span></a></li> <li><a href="login.html"><span>login</span></a></li> <li><a href="about.html"><span>about</span></a></li> </ul> </div> <table width="200" border="0" class="download"> <form name="download" action="<?php echo $_server['php_self']; ?>" method="post"> <caption align="top"> downloads: </caption> <tr> <td>select:</td> <td><select name="select"> <option value="hall tickets" selected="selected">hall tickets</option> <option value="results">results</option> </select> </td> </tr> <tr> <td>seat no.</td> <td><input type="text" name="seatno" maxlength="10" /></td> </tr> <tr> <td><input type="submit" name="download1" value="download"/></td> </tr> </form> </table> <table width="200" border="0" class="download"> <form name="upload" action="students.php" method="post"> <caption align="top"> uploads: </caption> <tr> <td>name:</td> <td><input type="text" name="name" maxlength="30"/></td> </tr> <tr> <td>education:</td> <td><input type="text" name="education" maxlength="30" /></td> </tr> <tr> <td>address:</td> <td><input type="text" name="education" maxlength="100"/></td> </tr> <tr> <td><input type="submit" name="upload" value="upload" /></td> </form> </table> </body> </html>
finally brought both php pages on 1 php page , used if...else condition, , successfull..!!
<html> <body> <input type="button" value=" print page " onclick="window.print();return false;" style="border-bottom-style:double;background-color:#ff6600;" align="right"/> <?php $host="localhost"; // host name $username="mt_prakash"; // mysql username $password="h.patil"; // mysql password $db_name="mt_test"; // database name $tbl_name="members"; // table name // connect server , select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); $select = $_post['select']; $seatno = $_post['seatno']; if ($select=='hall tickets'){ $query1 ="select * hallticket seatno='$seatno'"; $query2= mysql_query($query1); while ($row1 = mysql_fetch_array($query2)) { ?> <form name="hallticket" id="hallticket" method="post" action=""> <table width="763" id="hallticket1" border="1"> <tr> <td colspan="4" align="center" style="color:#3300ff"><h1>maharashtra tantra niketan shikshan mandal</h1> <h3>(established under govt. of maharashtra pt act)</h3> <br /> <span style="padding:3px 5px; background-color:#3366ff; border-radius:10px; color:#ffffff">hall ticket</span> <p></p></td> </tr> <tr> <td width="37"> </td> <td width="170">name:</td> <td width="373"><?php echo $row1['name']; ?></td> <td width="165" rowspan="3"><img src="" alt="photo" name="photo" width="86" height="92" id="photo" style="background-color: #ffffff" /></td> </tr> <tr> <td> </td> <td>exam date: </td> <td><?php echo $row1['examdate']; ?></td> </tr> <tr> <td> </td> <td>exam time: </td> <td><?php echo $row1['examtime']; ?></td> </tr> <tr> <td> </td> <td>exam center: </td> <td><?php echo $row1['examcenter']; ?></td> <td> </td> </tr> <tr> <td> </td> <td>seat no: </td> <td><?php echo $row1['seatno']; ?></td> <td><img src="" alt="signature" name="signature" width="87" height="32" id="photo" style="background-color: #ffffff" /></td> </tr> </table> </form> <?php } } else { $query3 ="select * result resultseatno='$seatno'"; $query4= mysql_query($query3); while ($row2 = mysql_fetch_array($query4)) { ?> <table width="806" cellpadding="10" class="upload" border="1" style="border-radius:0; background-color:#ffffff; border-collapse:collapse;"> <form action="upload.php" method="post" > <caption align="top"> result upload </caption> <tr> <td height="62" colspan="4" align="center"><h2 style=""><img src="mtnsm.jpg" width="84" height="103" style="float:left; clear:left"/>maharashtra tantra niketan shikshan mandal</h2> <p style="float:left" align="center"> </p> <h3 style="">*online result</h3></td> </tr> <tr> <td width="260"> name of student: </td> <td colspan="3"><?php echo $row2['resultname']; ?></td> </tr> <tr> <td>examination held in: </td> <td colspan="3"><?php echo $row2['resultlocation']; ?></td> </tr> <tr> <td>institute code : </td> <td colspan="2"><?php echo $row2['resultinstitute']; ?></td> <td width="327"> seat no: <?php echo $row2['resultseatno']; ?></td> </tr> <tr> <td>name of subject: </td> <td width="267">maximum marks </td> <td width="302">obtained marks </td> <td>grade</td> </tr> <tr> <td>talent search exam </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><p>a1 - 91 100</p> <p>a+ - 81 90</p> <p>a - 71 80</p> <p>b+ - 61 70</p> <p>b - 51 60</p> <p>c+ - 41 50</p> <p>c - 1 40</p></td> <td colspan="3"> </td> </tr> <tr> <td>date of result: </td> <td colspan="3"><?php echo $row2['resultdate']; ?></td> </tr> <tr> <td> </td> <td colspan="3" align="right"> </td> </tr> </form> </table> <?php } } ?> </body> </html>
Comments
Post a Comment