473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

auto generate student id, php function

pls i want php function that will generate student id like dms/15/01 serially, when entering new records, i want it to show in student reg_number column in registration form so that in can be inserted into database with the rest of information entered manually by the student.
thank you
Jan 5 '16 #1
3 5727
zmbd
5,501 Expert Mod 4TB
ahmad233, what have you tried so far?

People are more willing to help when you've shown that you've already made the attempt at solving the task at hand.

Also, you provide absolutely no information for the basis of the "student id"
Jan 5 '16 #2
i just want to make student registration form, i want student id field to generate student id like dm"department"/16"year"/001"serial number"
here is the code

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Essence Schools SIS</title>
  6. <style type="text/css">
  7. .topborder {
  8.     background-color: #FFFFFF;
  9.     height: 4cm;
  10.     width: 22.251cm;
  11.     border-top-style: solid;
  12.     border-right-style: solid;
  13.     border-bottom-style: solid;
  14.     border-left-style: solid;
  15.     border-top-color: #FF0;
  16.     border-right-color: #FF0;
  17.     border-bottom-color: #FF0;
  18.     border-left-color: #FF0;
  19.     font-size: 50px;
  20.     font-family: "Comic Sans MS", cursive;
  21.     color: #FFCC00;
  22.     position: absolute;
  23.     background-image: none;
  24.     background-position: 12cm 12cm;
  25. }
  26. .topborder {
  27.     text-align: center;
  28.     position: absolute;
  29.     vertical-align: baseline;
  30.     font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  31.     left: 216px;
  32.     top: 11px;
  33.     border-top-style: solid;
  34.     border-right-style: solid;
  35.     border-bottom-style: solid;
  36.     border-left-style: solid;
  37.     border-top-color: #FF0;
  38.     border-right-color: #FF0;
  39.     border-bottom-color: #FF0;
  40.     border-left-color: #FF0;
  41. }
  42. .centerborder {
  43.     height: auto;
  44.     width: 843px;
  45.     border-top-style: solid;
  46.     border-right-style: solid;
  47.     border-bottom-style: solid;
  48.     border-left-style: solid;
  49.     border-top-color: #FF0;
  50.     border-right-color: #FF0;
  51.     border-bottom-color: #FF0;
  52.     border-left-color: #FF0;
  53.     position: absolute;
  54.     left: 216px;
  55.     top: 176px;
  56. }
  57. body {
  58.     background-color: #FFF;
  59. }
  60. #apDiv1 {
  61.     position:absolute;
  62.     width:815px;
  63.     height:138px;
  64.     z-index:1;
  65.     left: 6px;
  66.     top: 9px;
  67. }
  68. #apDiv2 {
  69.     position:absolute;
  70.     width:434px;
  71.     height:219px;
  72.     z-index:1;
  73.     left: 209px;
  74.     top: 96px;
  75.     color: #003;
  76.     background-color: #CCC;
  77.     font-weight: bold;
  78. }
  79. .centerborder #apDiv2 #form1 label {
  80.     color: #003;
  81. }
  82. .form1 {
  83.     background-color: #FFF;
  84.     border-top-color: #D6D6D6;
  85.     border-right-color: #D6D6D6;
  86.     border-bottom-color: #D6D6D6;
  87.     border-left-color: #D6D6D6;
  88. }
  89. #apDiv3 {
  90.     position:absolute;
  91.     width:428px;
  92.     height:71px;
  93.     z-index:2;
  94.     left: 215px;
  95.     top: 29px;
  96. }
  97. middleapdev {
  98.     font-size: 36px;
  99. }
  100. .centerborder #apDiv3 p {
  101.     color: #003;
  102.     font-size: 24px;
  103.     font-weight: bold;
  104. }
  105. #apDiv4 {
  106.     position:absolute;
  107.     width:478px;
  108.     height:53px;
  109.     z-index:1;
  110.     left: 385px;
  111.     top: 186px;
  112. }
  113. #apDiv5 {
  114.     position:absolute;
  115.     width:284px;
  116.     height:254px;
  117.     z-index:2;
  118.     left: 273px;
  119.     top: 77px;
  120. }
  121. #apDiv6 {
  122.     position:absolute;
  123.     width:691px;
  124.     height:115px;
  125.     z-index:1;
  126. }
  127. .centerborder #apDiv6 #form1 {
  128.     font-weight: bold;
  129. }
  130. .contententpersonalinfor {
  131.     margin-top: 15px;
  132.     margin-left: 15px;
  133. }
  134. .centerborder #form1 fieldset table tr td {
  135.     text-align: right;
  136. }
  137. .centerborder #form1 fieldset table tr td {
  138.     text-align: center;
  139. }
  140. .centerborder #form1 fieldset table tr td {
  141.     text-align: right;
  142. }
  143. .centerborder #form1 fieldset table tr td {
  144.     text-align: justify;
  145. }
  146. .centerborder #form1 fieldset table tr td {
  147.     text-align: right;
  148. }
  149. .centerborder #form1 fieldset table tr td {
  150.     font-size: 16px;
  151. }
  152. .centerborder #form1 fieldset table tr td {
  153.     font-size: 13px;
  154. }
  155. </style>
  156. </head>
  157.  
  158. <body>
  159. <div class="topborder"><img src="img/ess header.jpg" width="829" height="150" alt="ESSENCE SCHOOL" />
  160.   <p>&nbsp;</p>
  161. </div>
  162. <p>&nbsp;</p>
  163. <p>&nbsp;  </p>
  164. <p>&nbsp;</p>
  165. <p>&nbsp;</p>
  166. <div id="apDiv4"><a href="menu.php" target="_self"><img src="img/home.PNG" alt="" name="HOME" width="100" height="50" id="HOME" /></a><a href="student regis.php" target="_self"><img src="img/enter rec.PNG" alt="" name="rec" width="120" height="50" id="rec" /></a><a href="view records.php" target="_self"><img src="img/view rec.PNG" alt="" name="view" width="120" height="50" id="view" /></a><a href="#" target="_self"><img src="img/schl fees.PNG" alt="" name="sch" width="120" height="50" id="sch" /></a></div>
  167. <p>&nbsp;</p>
  168. <div class="centerborder">
  169.   <p>&nbsp;</p>
  170.   <p>&nbsp;</p>
  171.   <form name="reg" action="code_exec.php" onsubmit="return validateForm()" method="post" enctype="multipart/form-data">
  172. <table width="274" border="0" align="center" cellpadding="2" cellspacing="0">
  173.   <tr>
  174.     <td colspan="2">
  175.         <div align="left">
  176.  
  177.          <script type="text/javascript">
  178. function validateForm()
  179. {
  180. var a=document.forms["reg"]["regno"].value;
  181. var b=document.forms["reg"]["surname"].value;
  182. var c=document.forms["reg"]["firstname"].value;
  183. var d=document.forms["reg"]["other"].value;
  184. var e=document.forms["reg"]["datepicker"].value;
  185. var f=document.forms["reg"]["stateoforigin"].value;
  186. var g=document.forms["reg"]["lga"].value;
  187. var h=document.forms["reg"]["gender"].value;
  188. var i=document.forms["reg"]["disability"].value;
  189. var j=document.forms["reg"]["datepicker2"].value;
  190. var k=document.forms["reg"]["class"].value;
  191. var l=document.forms["reg"]["photo"].value;
  192. var m=document.forms["reg"]["pname"].value;
  193. var n=document.forms["reg"]["occupation"].value;
  194. var o=document.forms["reg"]["contact"].value;
  195. var p=document.forms["reg"]["address"].value;
  196. if ((a==null || a=="") && (b==null || b=="") && (c==null || c=="") && (d==null || d=="") && (e==null || e=="") && (f==null || f=="") && (g==null || g=="") && (h==null || h=="") && (i==null || i=="") && (j==null || j=="") && (k==null || k=="")&& (l==null || l=="") && (m==null || m=="") && (n==null || n=="") && (o==null || o=="") && (p==null || p==""))
  197.   {
  198.   alert("All Field must be filled out");
  199.   return false;
  200.   }
  201. if (a==null || a=="")
  202.   {
  203.   alert("regno must be filled out");
  204.   return false;
  205.   }
  206. if (b==null || b=="")
  207.   {
  208.   alert("surname must be filled out");
  209.   return false;
  210.   }
  211. if (c==null || c=="")
  212.   {
  213.   alert("first name must be filled out");
  214.   return false;
  215.   }
  216. if (d==null || d=="")
  217.   {
  218.   alert("other must be filled out");
  219.   return false;
  220.   }
  221. if (e==null || e=="")
  222.   {
  223.   alert("date of birth must be filled out");
  224.   return false;
  225.   }
  226. if (f==null || f=="")
  227.   {
  228.   alert("state of origin must be filled out");
  229.   return false;
  230.   }
  231. if (g==null || g=="")
  232.   {
  233.   alert("lga must be filled out");
  234.   return false;
  235.   }
  236. if (h==null || h=="")
  237.   {
  238.   alert("gender must be filled out");
  239.   return false;
  240.   }
  241.   if (i==null || i=="")
  242.   {
  243.   alert("disability must be filled out");
  244.   return false;
  245.    }
  246.   if (j==null || j=="")
  247.   {
  248.   alert("date of addmission must be filled out");
  249.   return false;
  250.   }
  251.   if (k==null || k=="")
  252.   {
  253.   alert("class must be filled out");
  254.   return false;
  255.   }
  256.   if (l==null || l=="")
  257.   {
  258.   alert("passport must be inserted");
  259.   return false;
  260.    }
  261.   if (m==null || m=="")
  262.   {
  263.   alert("parent name must be filled out");
  264.   return false;
  265.    }
  266.   if (n==null || n=="")
  267.   {
  268.   alert("parent occupation must be filled out");
  269.   return false;
  270.    }
  271.   if (o==null || o=="")
  272.   {
  273.   alert("parent phone number must be filled out");
  274.   return false;
  275.    }
  276.   if (p==null || p=="")
  277.   {
  278.   alert("address be filled out");
  279.   return false;
  280.   }
  281. }
  282.  
  283. </script>
  284.  
  285.  
  286.  
  287.  
  288.   <form name="reg" action="code_exec.php" onsubmit="return validateForm()" method="post" enctype="multipart/form-data">
  289.     <fieldset>
  290.       <legend>PERSONAL INFORMATION</legend>
  291.       <table width="781" height="174" border="0">
  292.       <tr> <td width="136">REG. NO:</td>
  293.           <td> <label for="regno"></label>
  294.             <input type="text" name="regno" id="regno" /><?php echo $regno; ?></td>
  295.           </tr>
  296.         <tr>
  297.           <td width="135">SURNAME:</td>
  298.           <td> <label for="surname"></label>
  299.             <input type="text" name="surname" id="surname" /></td>
  300.           <td width="113"> FIRST NAME:</td>
  301.           <td width="150"><label for="firstname"></label>
  302.           <input type="text" name="firstname" id="firstname" /></td>
  303.           <td width="58">OTHER:</td>
  304.           <td width="149"><label for="other"></label>
  305.           <input type="text" name="other" id="other" /></td>
  306.         </tr>
  307.         <tr>
  308.           <td>DATE OF BIRTH:</td>
  309.              <td><link href="jquery-ui_themes_smoothness.css" rel="stylesheet" type="text/css" />
  310. <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  311. <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  312. <link rel="stylesheet" href="/resources/demos/style.css" />
  313.  
  314. <script type="text/javascript">
  315. $(document).ready(function() {
  316. $( "#datepicker" ).datepicker({ minDate: -90000, maxDate: "90Y+1M+7D",
  317. changeMonth: true, changeYear: true,
  318. numberOfMonths:1,
  319. dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  320. dateFormat:"yy/mm/dd",
  321. showAnim:"drop" });//fold, slide, blind, bounce, slideDown, show, fadeIn, clip.
  322. });
  323. </script><label for="datepicker"></label>
  324.           <input type="text" name="datepicker" id="datepicker" /></td>
  325.           <td>STATE OF ORIG:</td>
  326.           <td><label for="stateoforigin"></label>
  327.           <input type="text" name="stateoforigin" id="stateoforigin" /></td>
  328.           <td>L.G.A:</td>
  329.           <td><label for="lga"></label>
  330.           <input type="text" name="lga" id="lga" /></td>
  331.         </tr>
  332.         <tr>
  333.           <td>GENDER:</td>
  334.           <td><label for="gender"></label>
  335.           <input type="text" name="gender" id="gender" /></td>
  336.           <td>DISABILITY:</td>
  337.           <td><label for="disability2"></label>
  338.           <input type="text" name="disability" id="disability2" /></td>
  339.         </tr>
  340.         <tr>
  341.           <td>DATE OF ADMISS:</td>
  342.           <td><link href="jquery-ui_themes_smoothness2.css" rel="stylesheet" type="text/css" />
  343. <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  344. <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  345. <link rel="stylesheet" href="/resources/demos/style.css" />
  346.  
  347. <script type="text/javascript">
  348. $(document).ready(function() {
  349. $( "#datepicker2" ).datepicker({ minDate: -90000, maxDate: "90Y+1M+7D",
  350. changeMonth: true, changeYear: true,
  351. numberOfMonths:1,
  352. dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  353. dateFormat:"yy/mm/dd",
  354. showAnim:"drop" });//fold, slide, blind, bounce, slideDown, show, fadeIn, clip.
  355. });
  356. </script><label for="datepicker2"></label>
  357.           <input type="text" name="datepicker2" id="datepicker2" /></td>
  358.           <td>CLASS ADMITT:</td>
  359.           <td><label for="class"></label>
  360.           <input type="text" name="class" id="class" /></td>
  361.           </tr>               
  362.       </table> 
  363.               <table width="444" border="0">
  364.         <tr>
  365.           <td <label> Upload Passport</label>
  366.            <input type="hidden" name="size" value="350000">
  367.            <input type="file" name="photo"> 
  368.         </tr>
  369.       </table>
  370.  
  371.         <table width="510" border="0">
  372.           <tr>
  373.             <td>NAME OF PARENT/GUARDIAN :</td>
  374.             <td><label for="pname"></label>
  375.             <input type="text" name="pname" id="pname" /></td>
  376.           </tr>
  377.  
  378.           <p>&nbsp;</p>
  379.           <tr>
  380.             <td>PARENT/GUARDIAN OCCUPATION:</td>
  381.             <td><label for="occupation"></label>
  382.             <input type="text" name="occupation" id="occupation" /></td>
  383.           </tr>
  384.           <tr>
  385.             <td> PARENT/GUARDIAN PHONE NO:</td>
  386.             <td><label for="contact"></label>
  387.               <input type="text" name="contact" id="contact" /></td>
  388.           </tr>
  389.           <tr>
  390.             <td> PARENT/GUARDIAN ADDRESS:</td>
  391.             <td>    <label for="address"></label>
  392.               <input type="text" name="address" id="address" /></td>
  393.           </tr>
  394.         </table>
  395.  
  396.       <p>&nbsp;</p>
  397.     </fieldset>
  398.     <p>
  399.         <tr>
  400.                 <td><div align="center"></div></td>
  401.                 <td><input name="submit" type="submit" value="Submit" /></td>
  402.                 <td>&nbsp;</td>
  403.                 <td>&nbsp;</td>
  404.               </tr>
  405.      </p>
  406. </form>
  407.   <p>&nbsp;</p>
  408. </div>
  409. <p>&nbsp;</p>
  410. </body>
  411. </html>
  412.  
  413. here is the php processing file
  414.  
  415.   <?php 
  416.   if (isset($_POST['mop']))
  417.   {
  418.      $regno=$_POST['regno']; 
  419.      $cclass=$_POST['cclass'];
  420.      $term=$_POST['term'];
  421.      $datepicker3=$_POST['datepicker3']; 
  422.       $mop=$_POST['mop'];
  423.       $details=$_POST['details'];
  424.        $amount=$_POST['amount'];
  425.         $outstanding=$_POST['outstanding'];
  426.  
  427.  
  428.      $link=mysql_connect("localhost","root","rurumtown2012") or die("Cannot Connect to the database!");
  429.  
  430.      mysql_select_db("essence_sis", $link) or die ("Cannot select the database!");
  431.      $query=("INSERT INTO fee (regno, cclass, term, date, mop, details, amount, outstanding) values
  432.      ('".$regno."', '".$cclass."', '".$term."', '".$datepicker3."', '".$mop."', '".$details."', '".$amount."', '".$outstanding."')");
  433.      }
  434.  
  435.           if(!mysql_query($query,$link))
  436.           {die ("An unexpected error occured while saving the record, Please try again!");}
  437.           else
  438.          {
  439.           echo "New record saved successfully!";
  440.           }
  441.           header("location: enterfees.php?remarks=success");
  442.  
  443. mysql_close($con);
  444.  
  445. ?>
Jan 5 '16 #3
zmbd
5,501 Expert Mod 4TB
and what is it that your code is doing or not doing - we appreciate that you have the script; however, parsing thru 445 lines of scripting is a bit much to ask...
+ Where in the script is the "student id" being generated?
>> At some point you are going to have to connect to the MySQL server and pull the last serial number.
>> Where are you getting the department information?
>>> What criteria are you using the shorten the department name to its initials, will you need to connect to the database to pull that information too?

+ What is the script actually generating (or not :) )?
Jan 5 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Sebastien | last post by:
Hi, I am building a products database, linking sales and production. Each part has a unique sales Stock Code and Production Number. The sales stock code is a combination of letters and numbers...
2
by: SalimShahzad | last post by:
Dear Gurus, i had written following codes to auto generate the next claim no Private Const strC = "GCT/02/J/" Private Sub Command1_Click() Dim stra, stre As String Dim intb, intd As Integer...
3
by: SPG | last post by:
Hi, I am new to C#, and was wondering if there is an easy way to auto generate a Dataset and the relevant classes (IE: Adapter for updating etc) by pointing a wizard at the db? I am sure...
1
by: popsovy | last post by:
I am new to the discussion groups and to the .NET world, so this is probably a very basic question.. Is there any quick way in .NET to auto-generate data forms from typed datasets or SQL queries?...
8
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they...
1
by: gwhite1 | last post by:
I am using the auto-generate fields option because my query can be different based on what the user selects. But I would still like to set the column alignment but I can;t seem to access the...
8
by: dougawells | last post by:
Hi - I'm hoping for help with the auto-generation of a hyperlinked listing of all files in a directory. The server I use does not auto-generate this. So, when someone comes to this directory and...
1
by: ganesh22 | last post by:
hi... I am doing a project asp.net with C#.my requirement I want to do auto generate password for my application that means when user forget his password when he clicks a link it will auto...
0
by: ivyG | last post by:
How do you auto generate the name of the user who is logged in? For example, I had a Detail View to allow the user to insert the data, and i have a column named "Teacher In Charge 1". I wish...
2
by: Jagdish Patil | last post by:
I have project in asp.net with sql server backend. i want to auto generate a number for particular column. with the auto generated number i want to insert some other data in the same row same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.