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/
Related
I have read many articles related to this topic but none of these articles proffer exact solution to what I am trying to achieve.
I'll like to make "COMPUTER SCIENCE" a static text in the input filed for "Department in the following code".
<table>
<tr>
<td><label for="Username">Username</label></td>
<td><input name="txtusername" type="text" id="txtusername" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="Password">Password</label></td>
<td><input name="txtpassword" type="password" id="txtpassword" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="Lastname">Lastname</label></td>
<td><input name="txtlastname" type="text" id="txtlastname" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="Firstname">Firstname</label></td>
<td><input name="txtfirstname" type="text" id="txtfirstname" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="Sex">Sex</label></td>
<td>
<select name="sex" class="form-control" required>
<option value=""> ----- </option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</td>
</tr>
<tr>
<td><label for="ContactNo">Contact No</label></td>
<td><input name="txtcontactno" type="text" id="txtcontactno" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="MatricNo">Matric No</label></td>
<td><input name="txtmatricno" type="text" id="txtmatricno" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="Programme">Programme</label></td>
<td><input name="txtprogramme" type="text" id="txtprogramme" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="Department">Department</label></td>
<td> <input name="txtdept" type="text" id="txtdept" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="CFaculty">Faculty</label></td>
<td><input name="txtfaculty" type="text" id="txtfaculty" style="height:20px; width:208px" /></td>
</tr>
<tr>
<td><label for="UploadPhoto">UploadPhoto</label></td>
<td><input type="file" name="image" /> </td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="add" value="Register" id="submit" />
<input type="submit" name="Reset" value="Cancel" id="Reset" />
</td>
</tr>
</table>
I want to achieve a result similar to the output in the attached picture:
Any suggestion or recommendation is greatly appreciated.
As already mentioned, disabling the input field would be the first step.
<tr>
<td><label for="Department">Department</label></td>
<td><input name="txtdept" type="text" id="txtdept" style="height:20px; width:208px" disabled/></td>
</tr>
If the value of the department needs to be static, you can just define it directly in the input field.
<td><input name="txtdept" type="text" id="txtdept" style="height:20px; width:208px" value="COMPUTER SCIENCE" disabled/></td>
In case the department would have a correlation with a value from an other input field, you could theoretically use JS with some If-Statements.
$(document).ready(function(){
var txtdept = document.getElementById("txtdept");
txtdept.value = "COMPUTER SCIENCE";
});
Not too sure what you mean by static text but you have two ways of doing what is in the image: you can either add placeholder="COMPUTER SCIENCE" the input
<input name="txtdept" type="text" id="txtdept" style="height:20px; width:208px" placeholder="COMPUTER SCIENCE" />
and/or add value="COMPUTER SCIENCE".
<input name="txtdept" type="text" id="txtdept" style="height:20px; width:208px" placeholder="COMPUTER SCIENCE" value="COMPUTER SCIENCE" />
The placeholder is meant to show when the input is empty. The value will just be the default value of the input and can be changed by the user. You can add disabled to the input if you don't want the user to change the content of the input.
<input name="txtdept" type="text" id="txtdept" style="height:20px; width:208px" value="COMPUTER SCIENCE" disabled/>
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 a html table
If Production Profit % between:
<table id="tableDataInp">
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
</tr>
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
</tr>
</table>
How can I give a % sign at the end of each row? I tried using % sign after each but %is displayed at the top of table.
https://www.screencast.com/t/hZ9gebf1m Current Output
Expected Output : https://www.screencast.com/t/7OSfvlMgV5x % should be displayed in place of Red Square.
You could do it using CSS and an after element.
table td:last-child::after {
content: '%';
}
<table id="tableDataInp">
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
</tr>
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
</tr>
</table>
So the CSS selector selects the last td in each row and adds an after element with the content of %
You can then apply further styling to the after element (margin, font size etc).
Add after pseudo property
#tableDataInp tr:after{
content:"%";
color:#fff;
width:20px;
height:20px;
border-radius:5px;
background:red;
padding:3px;
}
https://jsfiddle.net/lalji1051/s25cvyda/2/
You could simply add an extra cell per row:
<table id="tableDataInp">
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
<td width="30">%</td>
</tr>
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
<td width="30">%</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
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.