I've created a simple HTML5 form, with the code below.
It successfully works in Chrome in W10, as well as in Chrome on my Android Phone.
The autosum function doesn't work on an iPad in Safari, nor Chrome.
What am I missing?
Cheers,
Stewart
<form onsubmit="return false" oninput="tta.value = parseInt(r1ta.value)+parseInt(r2ta.value)+parseInt(r3ta.value)+parseInt(r4ta.value);ttb.value = parseInt(r1tb.value)+parseInt(r2tb.value)+parseInt(r3tb.value)+parseInt(r4tb.value);te.value = parseInt(r1e.value)+parseInt(r2e.value)+parseInt(r3e.value)+parseInt(r4e.value)">
<table style="height: 97px;" width="216">
<tbody>
<tr>
<td>RINK</td>
<td>TEAM A</td>
<td>TEAM B</td>
<td>ENDS</td>
</tr>
<tr>
<td>1</td>
<td><input id="r1ta" name="r1ta" type="number" /></td>
<td><input id="r1tb" name="r1tb" type="number" /></td>
<td><input id="r1e" name="r1e" type="number" /></td>
</tr>
<tr>
<td>2</td>
<td><input id="r2ta" name="r2ta" type="number" /></td>
<td><input id="r2tb" name="r2tb" type="number" /></td>
<td><input id="r2e" name="r2e" type="number" /></td>
</tr>
<tr>
<td>3</td>
<td><input id="r3ta" name="r3ta" type="number" /></td>
<td><input id="r3tb" name="r3tb" type="number" /></td>
<td><input id="r3e" name="r3e" type="number" /></td>
</tr>
<tr>
<td>4</td>
<td><input id="r4ta" name="r4ta" type="number" /></td>
<td><input id="r4tb" name="r4tb" type="number" /></td>
<td><input id="r4e" name="r4e" type="number" /></td>
</tr>
<tr>
<td>TOTAL</td>
<td><output for="r1ta r2ta r3ta r4ta" name="tta"></output></td>
<td><output for="r1tb r2tb r3tb r4tb" name="ttb"></output></td>
<td><output for="r1e r2e r3e r4e" name="te"></output></td>
</tr>
</tbody>
</table>
</form>
Because your field's default value is not 0 it is null. so it cannot be able to sum 1 + null for ins.
Related
How can I make Jquery to detect if the input field inside the table is empty?
If inputs are empty I would to like to hide the row. How can I do it? I manage to hide the row if the input weren't inside the row.
<table id="entryTable">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<tr>
<tr>
<td><input type="text" name="f_name" /></td>
<td><input type="text" name="l_name" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" /></td>
<td><input type="text" name="l_name" /></td>
<td><input type="text" name="age" /></td>
</tr>
</table>
$('#entryTable tr').each(function() {
if ($(this).find('td:empty').length) $(this).remove();
});
You can try something like this:
$('#entryTable tbody tr').each(function() {
var n = $(this).find("td").filter(function() {
if ($("input", this).length) return $("input", this).val().length == 0;
return $(this).text().length == 0
})
if (n.length == $(this).find("td").length) $(this).remove();
});
Problem is that none of your td is empty because of the input.
Demo
$('#entryTable tbody tr').each(function() {
var n = $(this).find("td").filter(function() {
if ($("input", this).length) return $("input", this).val().length == 0;
return $(this).text().length == 0
})
if (n.length == $(this).find("td").length) $(this).remove();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="entryTable">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name="f_name" /></td>
<td><input type="text" name="l_name" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" /></td>
<td><input type="text" name="l_name" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" /></td>
<td><input type="text" name="l_name" value="name" /></td>
<td><input type="text" name="age" /></td>
</tr>
</tbody>
</table>
$('#entryTable tbody tr').each(function() {
var n = $(this).find("td").filter(function() {
if ($("input", this).length)
return $("input", this).val().length == 0;
return $(this).text().length == 0
})
if (n.length == $(this).find("td").length) $(this).remove();
});
tabel,tr,td{
border:1px solid black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="entryTable">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<tr>
<td><input type="text" name="f_name" value="do" /></td>
<td><input type="text" name="l_name" value="not" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" /></td>
<td><input type="text" name="l_name" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" value="do" /></td>
<td><input type="text" name="l_name" value="not" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" value="do" /></td>
<td><input type="text" name="l_name" value="not" /></td>
<td><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="text" name="f_name" value="do" /></td>
<td><input type="text" name="l_name" value="not" /></td>
<td><input type="text" name="age" /></td>
</tr>
</table>
i have the following html to Capture some Data.
<fieldset>
<legend>Rezept hinzufügen</legend>
<form action="php_act/create.php" method="post">
<table cellspacing="0" cellpadding="0">
<tr>
<th>Rezept Name</th>
<td><input type="text" name="name" placeholder="Rezept Name" /></td>
</tr>
<tr>
<th>Kurzbeschreibung</th>
<td><input type="text" name="kurztext" placeholder="Kurzbeschreibung" class="kurztext" /></td>
</tr>
<tr>
<th>Kategorie</th>
<td><input type="text" name="Kategorie" placeholder="Kategorien - mit , trennen" /></td>
</tr>
<tr>
<th>Anforderung</th>
<td><select name="Anforderung">
<option value="einfach">einfach</option>
<option value="mittel">mittel</option>
<option value="schwer">schwer</option>
</select></td>
</tr>
<tr>
<th>Zeit / Nährwerte</th>
<td><input type="text" name="zeit" placeholder="Zeit in minuten" /></td>
<td><input type="text" name="KCAL" placeholder="KCAL" size="6"/></td>
<td><input type="text" name="KH" placeholder="KH" size="6"/></td>
<td><input type="text" name="Eiweiss" placeholder="Eiweiss" size="6"/></td>
<td><input type="text" name="Fett" placeholder="Fett" size="6" /></td>
</tr>
<tr>
<th>Portionen</th>
<td><input type="text" name="Portionen" placeholder="Portionen" /></td>
</tr>
<tr>
<th>Zutaten</th>
<td><input type="text" name="zutaten" placeholder="Zutaten" /></td>
</tr>
<tr>
<th>Zubereitung</th>
<td><input type="text" name="zubereitung" placeholder="Zubereitung" /></td>
</tr>
<tr>
<th>FotoliaID</th>
<td><input type="text" name="FotoliaID" placeholder="FotoliaID" /></td>
</tr>
<tr>
<td><button type="submit">Speichern</button></td>
<td><button type="button">zurück</button></td>
</tr>
</table>
</form>
</fieldset>
There are some Input Type Text. i need to capture line breaks within the textfields. Problem is that "Enter" submits by default the. Is it possible to change that. Enter should add a line break in the textfield and not submit the form.
Can't you use textarea instead of textbox?
In a textarea you can insert enters.
https://www.w3schools.com/tags/tag_textarea.asp
Right now I have a table that looks like this:
The HTML for this table looks like this (I only included a brief snippet because the rest of the HTML looks the same):
<table class="table table-bordered table-condensed">
<tr>
<th>Days</th>
<th>Date</th>
<th>Calories</th>
<th>Happiness</th>
<th>Hunger</th>
<th>Motivation</th>
</tr>
<tr>
<td>1</td>
<td id="day">{{dayArray[0]}}</td>
<td id="calorie">{{calorieArray[0]}}</td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
</tr>
<tr>
<td>2</td>
<td id="day">{{dayArray[1]}}</td>
<td id="calorie">{{calorieArray[1]}}</td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
</tr>
<tr>
<td>3</td>
<td id="day">{{dayArray[2]}}</td>
<td id="calorie">{{calorieArray[2]}}</td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
</tr>
<tr>
I am using an array to populate the date because dependent on what the user chooses earlier on in the page, the date changes. The same goes for calories. I am using AngularJS's data binding to do this.
Does anyone have an idea of how to change the table's HTML to make it less repetitive? I have heard that anytime you begin to start copying and pasting things, it's a sign that you're writing bad code :(
use an ng-repeat
<table class="table table-bordered table-condensed">
<tr>
<th>Days</th>
<th>Date</th>
<th>Calories</th>
<th>Happiness</th>
<th>Hunger</th>
<th>Motivation</th>
</tr>
<tr ng-repeat="day in dayArray">
<td>{{ $index + 1 }}</td>
<td id="day-{{$index}}">{{day}}</td>
<td id="calorie-{{$index}}">{{calorieArray[$index]}}</td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
<td><input placeholder="0" /></td>
</tr>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="lightgray">
<fieldset>
<legend align="center"><blink><font color="grakgreen">Registration</font></blink></legend>
<form action="SaveServlet" method="post">
<table align="center">
<tr>
<th colspan="6">APPLICATION FOR EMPLOYMENT<BR>(Pre-Employment Questionnaire)</th>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">PERSONAL INFORMATION</th>
</tr>
<tr>
<td>NAME:</td>
<td><input type="text" name="lnam" value="" size="30" placeholder="last name"></td>
<td><input type="text" name="fnam" value="" placeholder="first name"></td>
<td colspan="2"><input type="text" name="mnam" value=""size="46" placeholder="middle name"></td>
</tr>
<tr>
<td>PRESENT ADDRESS:</td>
<td><input type="text" name="stree" value=""size="30"placeholder="Street or House NO:"></td>
<td><input type="text" name="cit" value="" placeholder="city"></td>
<td><input type="text" name="stat" value="" placeholder="state"></td>
<td><input type="text" name="zi" value="" placeholder="zip code"></td>
</tr>
<tr>
<td>PERMANENT ADDRESS:</td>
<td><input type="text" name="pstree" value=""size="30" placeholder="Street or House NO:"></td>
<td><input type="text" name="pcit" value="" placeholder="city"></td>
<td><input type="text" name="pstat" value=""placeholder="state"></td>
<td><input type="text" name="pzi" value="" placeholder="zip code"></td>
</tr>
<tr>
<td>PHONE NUMBER:</td>
<td><input type="text" name="phn" value="" size="30"placeholder="Phnoe number"></td>
<td colspan="2">ALTERNATE PHONE NUMBER:</td>
<td><input type="text" name="alpn" value=""placeholder="Alternate phone number"></td>
</tr>
<tr>
<td colspan="3">ARE YOU PREVENTED FROM LAWFULLY BECOMEING EMPLOYEED IN THIS COUNTRY BECAUSE OF VISA OR IMMIGRATION STATUS?</td>
<td colspan="2">Yes<input type="radio" name="ye" value="yes">No<input type="radio" name="ye" value="no"></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">EMPLOYEMENT DESIRED</th>
</tr>
<tr>
<td>POSITION:</td>
<td><input type="text" name="positio" value="" size="30"></td>
<td>DATE YOU CAN START:</td>
<td><input type="text" name="cdat" value=""></td>
<td>SALARY DESIRED:</td>
<td><input type="text" name="salar" value=""></td>
</tr>
<tr>
<td>ARE YOU EMPLOYEED NOW?</td>
<td><input type="text" name="empno" value=""size="30"></td>
<td colspan="3">IF SO MAY WE INQUIRE OF YOUR PRESENT EMPLOYER? </td>
<td><input type="text" name="inquir" value=""></td>
</tr>
<tr>
<td>EVER APPLIED TO THIS COMPANY BEFORE?</td>
<td><input type="text" name="applie" value=""size="30"></td>
<td>WHERE?</td>
<td><input type="text" name="wher" value=""></td>
<td>WHEN?</td>
<td><input type="text" name="whe" value=""></td>
</tr>
<tr>
<td>REFERED BY:</td>
<td><input type="text" name="rnam" value=""size="30"></td>
</tr>
<tr>
</tr>
<tr bgcolor="lightgreen">
</tr>
<tr>
<th>EDUCATION</th>
<th>NANME AND LOCATION OF SCHOOL</th>
<th>*NO OF YEARS ATTENDED</th>
<th>*DID YOU GRADUATE?</th>
<th>SUBJECTS STUDIED</th>
</tr>
<tr>
<td>SSC</td>
<td><input type="text" name="schol" value=""size="30"></td>
<td><input type="text" name="year" value=""></td>
<td><input type="text" name="graduat" value=""></td>
<td><input type="text" name="subject" value=""></td>
</tr>
<tr>
<td>INTER/DIPLOMA</td>
<td><input type="text" name="nschol" value=""size="30"></td>
<td><input type="text" name="nyear" value=""></td>
<td><input type="text" name="ngraduat" value=""></td>
<td><input type="text" name="nsubject" value=""></td>
</tr>
<tr>
<td>DEGREE/B.TECH/B.E</td>
<td><input type="text" name="naschol" value="" size="30"></td>
<td><input type="text" name="nayear" value=""></td>
<td><input type="text" name="nagraduat" value=""></td>
<td><input type="text" name="nasubject" value=""></td>
</tr>
<tr>
<td>PG</td>
<td><input type="text" name="nameschol" value="" size="30"></td>
<td><input type="number" name="nameyear" value=""></td>
<td><input type="text" name="namegraduat" value=""></td>
<td><input type="text" name="namesubject" value=""></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">GENERAL</th>
</tr>
<tr>
<td>SUBJECTS OF SPECICAL STUDY OR RESEARCH WORK</td>
<td><textarea rows="3" cols="35" name="specia"></textarea></td>
<td>SPECIAL SKILLS</td>
<td colspan="2"><textarea rows="3" cols="47" name="skill"></textarea></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6"><b>FORMER EMPLOYERS</b>(LIST BELLOW LAST THREE EMPLOYERS, STARTING WITH LAST ONE FIRST).</th>
</tr>
<tr>
<th colspan="2"> DATE MONTH AND YEAR</th>
</tr>
<tr>
<th>From</th>
<th>TO</th>
<th>NAME AND ADDRESS OF EMPLOYER</th>
<th>SALARY</th>
<th>POSITION</th>
<th>REAON FOR LEAVING</th>
</tr>
<tr>
<td><input type="text" name="fdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="tdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="nem" size="35"></td>
<td><input type="text" name="nsalar"></td>
<td><input type="text" name="npositio"></td>
<td><input type="text" name="nreaso"></td>
</tr>
<tr>
<td><input type="text" name="efdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="etdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="eem" size="35"></td>
<td><input type="text" name="esalar"></td>
<td><input type="text" name="epositio"></td>
<td><input type="text" name="ereaso"></td>
</tr>
<tr>
<td><input type="text" name="dfdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="dtdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="dem"size="35"></td>
<td><input type="number" name="dsalar"></td>
<td><input type="text" name="dpositio"></td>
<td><input type="text" name="dreaso"></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">REFERENCES:GIVE THE NAME NAMES OF 3 PERSONS NOT RELATED TO YOU, WHOM YOU HAVE KNOW AT LEAST ONE YEAR.</th>
</tr>
<tr>
<th>NAME</th>
<th>ADDRESS</th>
<th>BUSSINESS</th>
<th>YEARS ACQUAINTED</th>
</tr>
<tr>
<td><input type="text" name="unam" value=""></td>
<td><input type="text" name="uaddres" value=""></td>
<td><input type="text" name="ubusines" value=""></td>
<td><input type="text" name="uyea" value=""></td>
</tr>
<tr>
<td><input type="text" name="knam" value=""></td>
<td><input type="text" name="kaddres" value=""></td>
<td><input type="text" name="kbusines" value=""></td>
<td><input type="text" name="kyea" value=""></td>
</tr>
<tr>
<td><input type="text" name="nname" value=""></td>
<td><input type="text" name="naddress" value=""></td>
<td><input type="text" name="nbusiness" value=""></td>
<td><input type="text" name="nyear" value=""></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
</table>
<center>
<input type="reset" value="reset">
<input type="submit" value="submit">
</center>
</form>
</fieldset>
</body>
</html>
SaveServlet code, I used annotation
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("html/text");
PrintWriter out=res.getWriter();
String lnam=req.getParameter("lnam");
String fnam=req.getParameter("fnam");
String mnam=req.getParameter("mnae");
String stree=req.getParameter("stree");
String cit=req.getParameter("cit");
String stat=req.getParameter("stat");
String zi=req.getParameter("zi");
String pstree=req.getParameter("pstree");
String pcit=req.getParameter("pcit");
String pstat=req.getParameter("pstat");
String pzi=req.getParameter("pzi");
String phn=req.getParameter("phn");
String alpn=req.getParameter("alpn");
String ye=req.getParameter("ye");
String positio=req.getParameter("positio");
String cdat=req.getParameter("cdat");
String salar=req.getParameter("salar");
String empno=req.getParameter("empno");
String inquir=req.getParameter("inquir");
String applie=req.getParameter("applie");
String wher=req.getParameter("wher");
String whe=req.getParameter("whe");
String rnam=req.getParameter("rnam");
String schol=req.getParameter("schol");
String year=req.getParameter("year");
String graduat=req.getParameter("graduat");
String subject=req.getParameter("subject");
String nschol=req.getParameter("nschol");
String nyear=req.getParameter("nyear");
String ngraduat=req.getParameter("ngraduat");
String nsubject=req.getParameter("nsubject");
String naschol=req.getParameter("naschol");
String nayear=req.getParameter("nayear");
String nagraduat=req.getParameter("nagraduat");
String nasubject=req.getParameter("nasubject");
String nameschol=req.getParameter("nameschol");
String nameyear=req.getParameter("nameyear");
String namegraduat=req.getParameter("namegraduat");
String namesubject=req.getParameter("namesubject");
String specia=req.getParameter("specia");
String skill=req.getParameter("skill");
String fdat=req.getParameter("fdat");
String tdat=req.getParameter("tdat");
String nem=req.getParameter("nem");
String nsalar=req.getParameter("nsalar");
String npositio=req.getParameter("npositio");
String nreaso=req.getParameter("nreaso");
String efdat=req.getParameter("efdat");
String etdat=req.getParameter("etdat");
String eem=req.getParameter("eem");
String esalar=req.getParameter("esalar");
String epositio=req.getParameter("epositio");
String ereaso=req.getParameter("ereaso");
String dfdat=req.getParameter("dfdat");
String dtdat=req.getParameter("dtdat");
String dem=req.getParameter("dem");
String dsalar=req.getParameter("dsalar");
String dpositio=req.getParameter("dpositio");
String dreaso=req.getParameter("dreaso");
String unam=req.getParameter("unam");
String uaddres=req.getParameter("uaddres");
String ubusines=req.getParameter("ubusines");
String uyea=req.getParameter("uyea");
String knam=req.getParameter("knam");
String kaddres=req.getParameter("kaddres");
String kbusines=req.getParameter("kbusines");
String kyea=req.getParameter("kyea");
String nnam=req.getParameter("nnam");
String naddres=req.getParameter("naddres");
String nbusines=req.getParameter("nbusines");
String nyea=req.getParameter("nyea");
Empb b=new Empb();
b.setLnam(lnam);
b.setFnam(fnam);
b.setMnam(mnam);
b.setStree(pstree);
b.setCit(cit);
b.setStat(stat);
b.setZi(zi);
b.setPstree(pstree);
b.setPcit(pcit);
b.setPstat(pstat);
b.setPzi(pzi);
b.setPhn(phn);
b.setAlpn(alpn);
b.setYe(ye);
b.setPositio(positio);
b.setCdat(cdat);
b.setSalar(salar);
b.setEmpno(empno);
b.setInquir(inquir);
b.setApplie(applie);
b.setWher(wher);
b.setWhe(whe);
b.setRnam(rnam);
b.setSchol(schol);
b.setYear(year);
b.setGraduat(graduat);
b.setSubject(subject);
b.setNschol(nschol);
b.setNyear(nyear);
b.setNgraduat(ngraduat);
b.setNsubject(nsubject);
b.setNaschol(naschol);
b.setNayear(nayear);
b.setNagraduat(nagraduat);
b.setNasubject(nasubject);
b.setNameschol(nameschol);
b.setNameyear(nameyear);
b.setNamegraduat(namegraduat);
b.setNamesubject(namesubject);
b.setSpecia(specia);
b.setSkill(skill);
b.setFdat(fdat);
b.setTdat(tdat);
b.setNem(nem);
b.setNsalar(nsalar);
b.setNpositio(npositio);
b.setNreaso(nreaso);
b.setEfdat(efdat);
b.setEtdat(etdat);
b.setEem(eem);
b.setEsalar(esalar);
b.setEpositio(epositio);
b.setEreaso(ereaso);
b.setDfdat(dfdat);
b.setDtdat(dtdat);
b.setDem(dem);
b.setDsalar(dsalar);
b.setDpositio(dpositio);
b.setDreaso(dreaso);
b.setUnam(unam);
b.setUaddres(uaddres);
b.setUbusines(ubusines);
b.setUyea(uyea);
b.setKnam(knam);
b.setKaddres(kaddres);
b.setKbusines(kbusines);
b.setKyea(kyea);
b.setNnam(nnam);
b.setNaddres(naddres);
b.setNbusines(nbusines);
b.setNyea(nyea);
int status=EmpDbs.save(b);
if(status>0)
{
out.print("<p>Record saved successfully!</p>");
req.getRequestDispatcher("SoftEmp.html").include(req, res);
}
else
{
out.println("Sorry! unable to save record");
}
out.close();
}
}
When I click on submit button SaveServlet is downloading like shown in the image but values are inserted and page is not refresh/rested:
Try using
<input type="submit" value="submit" name="submit"/>
I am new to mysql and sql. I want to create a table for entering 12 months and 31 days infront of it. I am not getting how structurise it.
In left hand side i should get all the months name and infront of each month i will enter 31 days each.
if i use
CREATE TABLE allocate (
id INT,
month VARCHAR(50), days INT(10)
);
it will not solve my purpose.
here is the css design of the table where the data will be entered and same i need the table also in mysql
<table width="99%" border="1" cellspacing="1" cellpadding="1" align="center">
<form name="form1" action="submit.php" method="post">
<tr bgcolor="#00BFFF">
<td><strong>Month</strong></td>
<td width="3%">1</td>
<td width="3%">2</td>
<td width="3%">3</td>
<td width="3%">4</td>
<td width="3%">5</td>
<td width="3%">6</td>
<td width="3%">7</td>
<td width="3%">8</td>
<td width="3%">9</td>
<td width="3%">10</td>
<td width="3%">11</td>
<td width="3%">12</td>
<td width="3%">13</td>
<td width="3%">14</td>
<td width="3%">15</td>
<td width="3%">16</td>
<td width="3%">17</td>
<td width="3%">18</td>
<td width="3%">19</td>
<td width="3%">20</td>
<td width="3%">21</td>
<td width="3%">22</td>
<td width="3%">23</td>
<td width="3%">24</td>
<td width="3%">25</td>
<td width="3%">26</td>
<td width="3%">27</td>
<td width="3%">28</td>
<td width="3%">29</td>
<td width="3%">30</td>
<td width="3%">31</td>
</tr>
<tr>
<td>January</td>
<td><input type="text" name="jan1" id="jan1" style="width:87%;" /></td>
<td><input type="text" name="jan2" id="jan2" style="width:87%;" /></td>
<td><input type="text" name="jan3" id="jan3" style="width:87%;" /></td>
<td><input type="text" name="jan4" id="jan4" style="width:87%;" /></td>
<td><input type="text" name="jan5" id="jan5" style="width:87%;" /></td>
<td><input type="text" name="jan6" id="jan6" style="width:87%;" /></td>
<td><input type="text" name="jan7" id="jan7" style="width:87%;" /></td>
<td><input type="text" name="jan8" id="jan8" style="width:87%;" /></td>
<td><input type="text" name="jan9" id="jan9" style="width:87%;" /></td>
<td><input type="text" name="jan10" id="jan10" style="width:87%;" /></td>
<td><input type="text" name="jan11" id="jan11" style="width:87%;" /></td>
<td><input type="text" name="jan12" id="jan12" style="width:87%;" /></td>
<td><input type="text" name="jan13" id="jan13" style="width:87%;" /></td>
<td><input type="text" name="jan14" id="jan14" style="width:87%;" /></td>
<td><input type="text" name="jan15" id="jan15" style="width:87%;" /></td>
<td><input type="text" name="jan16" id="jan16" style="width:87%;" /></td>
<td><input type="text" name="jan17" id="jan17" style="width:87%;" /></td>
<td><input type="text" name="jan18" id="jan18" style="width:87%;" /></td>
<td><input type="text" name="jan19" id="jan19" style="width:87%;" /></td>
<td><input type="text" name="jan20" id="jan20" style="width:87%;" /></td>
<td><input type="text" name="jan21" id="jan21" style="width:87%;" /></td>
<td><input type="text" name="jan22" id="jan22" style="width:87%;" /></td>
<td><input type="text" name="jan23" id="jan23" style="width:87%;" /></td>
<td><input type="text" name="jan24" id="jan24" style="width:87%;" /></td>
<td><input type="text" name="jan25" id="jan25" style="width:87%;" /></td>
<td><input type="text" name="jan26" id="jan26" style="width:87%;" /></td>
<td><input type="text" name="jan27" id="jan27" style="width:87%;" /></td>
<td><input type="text" name="jan28" id="jan28" style="width:87%;" /></td>
<td><input type="text" name="jan29" id="jan29" style="width:87%;" /></td>
<td><input type="text" name="jan30" id="jan30" style="width:87%;" /></td>
<td><input type="text" name="jan31" id="jan31" style="width:87%;" /></td>
</tr>
Someone plz suggest me how to structurise it.
thanks
I believe you need to create a table with a column named "MONTH" and 30 other columns naming from DAY1-DAY30.I don't understand the purpose of such a table. Nevertheless
The query for table creation in SQL is:
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
....
);
For your requirement, you can use:
CREATE TABLE allocate (
Month VARCHAR(50), Day1 INT(3),Day2 INT(3),Day4 INT(3),......................,Day30 INT(3)
);
If you are new to SQL,i suggest you to go through the below links to understand the basics concepts of rdbms:
http://www.w3schools.com/sql/