Change this $_POST['check_option']; to $_POST['refID'];
You are posting refId with field name 'refID'
Change this $_POST['check_option']; to $_POST['refID'];
You are posting refId with field name 'refID'
Your code is working, disabled the 'start' button after i click on 'start' button.
And If you want to hide this button after click, you can use ...
function newtext()
{
document.myform.mytext.style.display = 'none';
setTimeout("moretext()",9000);
}
If you have repeated Id, and you don't want to change the Id name
You can use the following code ...
var myPTags = document.getElementsByTagName("p");
for(var i = 0; i < myPTags.length; i++){
if(myPTags[i].id == "f2") {
myPTags[i].innerHTML = q2;
}
}
document.getElementById("f1").innerHTML = q1;
//document.getElementById("f2").innerHTML = q2;
document.getElementById("f3").innerHTML = q3;
setTimeout("moretext()",9000);
Insted of
document.getElementById("f1").innerHTML = q1;
document.getElementById("f2").innerHTML = q2;
document.getElementById("f3").innerHTML = q3;
setTimeout("moretext()",9000);
Hi, @diafole .Good one.
Only One suggestion
I think, checking with Id is better than checking with name ...
Name Can be repeate ... Is it ?
Tyr this :
$result1 = mysql_query("SELECT id, name FROM allparks");
while ($row1 = mysql_fetch_array($result1)) {
echo '<h3>'.$row1['name'].'</h3><ul>';
$result2 = mysql_query("SELECT feat_name
FROM allparks
LEFT JOIN prkcombine ON allparks.id = prkcombine.pk_id
LEFT JOIN prkfeature ON prkcombine.pkfeat_id = prkfeature.pkfeat_id
WHERE allparks.id =".$row1['id']);
while ($row2 = mysql_fetch_array($result2)) {
echo '<li>'.$row2['feat_name'].'</li>';
}
echo '</ul>';
}
Compare Today date and Dead line date...
If Today date is less than deadline date , Print your Prompt
message in blinking area..
If you have any doubt in date and date comparison, please check
Hi;
In your script, startTime & endTime are not defined ...
And asign these values in your form, like
<input type="hidden" name="event_sub_stime1" value="2013-01-09" />
<input type="hidden" name="event_sub_etime1" value="2013-01-14" />
Check this Exg
Your index file:
<!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=utf-8" />
<title>Form - validate - Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<form method="post" name="myForm">
<select id="sltOption" name="sltOption">
</select>
</form>
<script type="text/javascript">
$(function (){
$.ajax({
type:"post",
url:"phpfile.php",
success:function(response){
$('#sltOption').html(response);
}
});
})
</script>
</body>
</html>
&
your php file:
<?php
echo "<option> add to list1 </option>";
echo "<option> add to list2 </option>";
?>
Check this Ex.. I think it will help you.....
<!DOCTYPE html>
<html>
<HEAD>
<SCRIPT language="JavaScript">
<!--hide
function newtext()
{
var q1=Math.floor(Math.random()*11)
document.myform.mytext.value=q1*2;
document.getElementById('q1Value').innerHTML=q1;
setTimeout("moretext()",4000);
}
function moretext()
{
document.myform.mytext.disabled = true;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM name="myform">
<table width='600' cellpadding='5' cellspacing='5' border='1'>
<tr><td colspan=6 align='right'><INPUT TYPE="button" name="but1" value="start " onClick="newtext()"></td></tr>
<tr> <td> <span id="q1Value">0</span> * 2 = </td> <td> <INPUT type="text" name="mytext" value="0" size="30"> </td> </tr> // once i click start, how can i see random value of q1 in html row?
<tr><td colspan=6 align='right'><INPUT TYPE="button" name="but1" value="Submit!" onClick="newtext()"></td></tr>
</table>
</FORM>
</body>
</html>
@Veedeoo Methode is good ...
You can use your own methode with some changes like
while ($row = mysql_fetch_array($result)) {
echo "<a><img src='";
echo $row['ImagePath']."'";
echo " alt=";
echo "'Country Music Nightclub Orlando'";
echo " Title='" .$row['ArtistDate']."'";
echo " /></a>";
}
For to implement this you should know hardware section also ...
Check this ..
Try this
<?php
$yourString = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vulputate, purus mollis volutpat faucibus, velit ligula egestas neque, ac gravida ante lacus et dolor. Maecenas blandit aliquet sem ac suscipit. Proin nec tortor dui. Sed bibendum mollis elementum.';
$strlimit=100;
echo substr ($yourString,0, $strlimit).' .............';
?>
Ymax<input type="text" name="Ymax" id="Ymax" size="15">
<input type="button" name="submit" class="submitBtn" VALUE="Submit">
<script type="text/javascript">
$(function(){
$('.submitBtn').click(function(){
$.post('otherPhpPage.php',{Ymax: $('#Ymax').val()},function(data){
alert(data);
});
});
});
</script>
<!--########## In otherPhpPage.php ######## -->
<?php
echo $yMax=$_REQUEST['Ymax'];
?>
Result of this code will show an alert with your entered Ymas value
Try This
<!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=utf-8" />
<title>Form - validate - Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<form method="post" name="myForm">
<span class="formError email">Please Enter Valid Email</span>
<input type="text" name="Email" id="email" onKeyUp="checkEmail()" />
<input type="submit" value="Send" name="submitButton" />
</form>
<style>
.formError{ display:none; }
</style>
<script type="text/javascript">
function checkEmail(){
var email = $("#email").val();
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
if(email=='') $('.email').show();
else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length) $('.email').show();
else $('.email').hide()
}
</script>
</body>
</html>
Try this
<!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=utf-8" />
<title>Form - Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div class="formDiv">
<table id="myTable" width="600px" cellpadding="0px" cellspacing="0px">
<tr><td>First Name</td><td><input type="text" name="txtFirstName[]" /></td></tr>
<tr><td>Last Name</td><td><input type="text" name="txtLastName[]" /></td></tr>
</table>
</div>
<hr />
<div class="appendDiv">
</div>
<input class="addNewForm" type="button" value="Add" >
<script type="text/javascript">
$(function(){
$('.addNewForm').live('click',function(){
$('.appendDiv').append('<div class="subForm">'+$('.formDiv').html()+'<input class="deleteForm" type="button" value="Delete" ><hr /></div>');
});
$('.deleteForm').live('click',function(){
$(this).closest('.subForm').remove();
});
});
</script>
</body>
</html>
Try this
<!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=utf-8" />
<title>Toggle-Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
#flip
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#box1
{ margin:10px;
height:auto;
}
#panel1,#panel2,#panel3
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
padding:50px;
display:none;
}
</style>
</head>
<body>
<div id="flip" rel="1" >Click to slide the panel down or up</div>
<div id="panel1">Hello world!</div>
<div id="box1" >
<div id="flip" rel="2" >Click to slide the panel down or up</div>
<div id="panel2">Hello world!</div>
</div>
<div id="box1">
<div id="flip" rel="3" >Click to slide the panel down or up</div>
<div id="panel3">Hello world!</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("#flip").live('click', function(){
var val=$(this).attr('rel');
$("#panel"+val).slideToggle(500);
});
});
</script>
</html>
Hi @bettybarnes;
I like to use jquery, its very easy for me..
you check the logic what I used..and try..
Try this
<!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=utf-8" />
<title>Test-String-Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<title>Exam entry</title>
</head>
<body>
<script type="text/javascript">
$(function(){
var str = "INC300051546,INC300051553,INC300051561,INC300051579";//Test your string here
var seperators = ['.',';'];// add your expected seperators here
var firstFlag = true;
var secondFlag = true;
var thirdFlag = true;
var seperatorLength = seperators.length;
//chacking other separator in the given string
for(var i=0;i<seperatorLength;i++) {
if(str.indexOf(seperators[i])>0) {
firstFlag=false;
}
}
if(firstFlag==true){
var splitStr = str.split(',');
for(var j=0;j<splitStr.length;j++){
//check first 3 charectors equals to INC
if(splitStr[j].substr(0, 3)!='INC') secondFlag = false;
// check other char number length is 9
else if(splitStr[j].replace('INC','').length!=9) thirdFlag = false;
}
if(secondFlag == false) alert('INC is not in proper order');
if(thirdFlag == false) alert('Error in 9 digits');
}
else alert('String contains other seperators');
});
</script>
</body>
Try this
<!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=utf-8" />
<title>Text-Link-Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<a href="#NOD" class="showSections" rel="show">Show information</a>
<div class="catSections" style="display: none;">
<h1>Helloo</h1>
</ul>
</div>
<script type="text/javascript">
$(function(){
$('.showSections').live('click', function() {
if($(this).attr('rel')=='show'){
$('.catSections').fadeIn();
$('.showSections').attr('rel','hide');
$('.showSections').html('Hide information');
}
else if ($(this).attr('rel')=='hide') {
$('.catSections').fadeOut();
$('.showSections').attr('rel','show');
$('.showSections').html('Show information');
}
});
});
</script>
</body>
</html>
Try this
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
var artists_arr = new Array();
artists_arr[0] = "The Beatles";
artists_arr[1] = "The Doors";
artists_arr[2] = "The Cascades";
for (i=0;i<artists_arr.length;i++)
{
$('#Artists').append('<option value="'+artists_arr[i].toUpperCase()+'">'+artists_arr[i].toUpperCase()+'</option>');
}
<?php
if(isset($_POST['submit'])){
?>
var val = '<?php echo $_POST['artists']; ?>';
$("#Artists option").filter(function() { return $(this).text() == val;}).attr('selected', true);
<?php
}
?>
});
</script>
<title>Artists Page</title>
</head>
<body>
<Form method="POST" action="#">
Select your favorite artist: <select id="Artists" name="artists"></select>
<input type="submit" name="submit" value="Ok" />
</Form>
<?php if(!isset($_POST['submit'])){
} else{
echo "Your favorie artist is: ".$_POST['artists'];
}
?>
</html>
In your table, set a field with primary key and auto increment options , ie ; Row ID;
Then ; in your query , set
SELECT FieldNameId FROM your_Table ORDER BY FieldNameId DESC LIMIT 0, 1;
the result of this query will give last row Id
Try this
<!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=utf-8" />
<title>Table-Text-Area Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<table id="myTable" width="200px" cellpadding="0px" cellspacing="0px">
<tr><td><label for="Cname">Â No of Partipants:</label></td><td>
<select style="width:160px;" id="text" name="participants" required="required" >
<option id="" value="0" name="">-Select participant-</option>
<option id="1" value="1" name="" >1</option>
<option id="" value="2" name="" >2</option>
<option id="" value="3" name="">3</option>
<option id="" value="4" name="">4</option>
<option id="" value="5" name="">5</option>
<option id="" value="6" name="">6</option>
<option id="" value="7" name="">7</option>
<option id="" value="8" name="">8</option>
<option id="" value="9" name="">9</option>
<option id="" value="10" name="">10</option>
<option id="" value="11" name="">11</option>
<option id="" value="12" name="">12</option>
<option id="" value="13" name="">13</option>
<option id="" value="14" name="">14</option>
<option id="" value="15" name="">15</option>
<option id="" value="16" name="">16</option>
<option id="" value="17" name="">17</option>
<option id="" value="18" name="">18</option>
<option id="" value="19" name="">19</option>
<option id="" value="20" name="">20</option>
<option id="" value="21" name="">21</option>
<option id="" value="22" name="">22</option>
<option id="" value="23" name="">23</option>
<option id="" value="24" name="">24</option>
<option id="" value="25" name="">25</option>
<option id="" value="26" name="">26</option>
<option id="" value="27" name="">27</option>
<option id="" value="28" name="">28</option>
<option id="" value="29" name="">29</option>
<option id="" value="30" name="">30</option>
<option id="" value="31" name="">More</option>
</select>
</td></tr>
</table>
<table id="myFilterTable" width="200px" cellpadding="0px" cellspacing="0px">
</table>
<script type="text/javascript">
$(function(){
$('#text').change(function(){
$('#myFilterTable').html('');
var sltdValue = $(this).val();
var i;
for(i=0;i<sltdValue;i++) {
$('#myFilterTable').append('<tr><td>Participant</td><td><textarea name="txtarea[]"></textarea></td></tr>');
}
});
});
</script>
</body>
</html>
Try this Exg :
<!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=utf-8" />
<title>Table Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<table id="myTable" width="200px" cellpadding="0px" cellspacing="0px">
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
<script type="text/javascript">
$(function(){
$('#myTable').mouseover(function() {
$(this).css('text-align','center');
$(this).css('border','1px solid');
$(this).css("background-color","#FF0000");
});
$('#myTable').mouseout(function() {
$(this).css('text-align','left');
$(this).css('border','0px');
$(this).css("background-color","#FFFFFF");
});
});
</script>
</body>
</html>
Pass students id's ,in your form
with
<input type="checkbox" checked="checked" name="att[]" value="1" />
<input type="hidden" name="stdId[]" value="<?php echo $id; ?>" />
in attendance.php
<?php
$att = $_POST['att'];
$stdId = $_POST['stdId'];
foreach($att as $key => $attendance) {
$at = $attendance ? 'P' : 'N';
$query = "INSERT INTO `attendance`(`stud_id`,`att`) VALUES ('".$stdId[$key]."','".$at."') ";
$result = mysql_query($query);
}
?>
change this
<div class="Page page1" style="display: none;">
<h1>Gallery-1</h1>
</div>
To
<div class="Page page1" style="display: block;">
<h1>Gallery-1</h1>
</div>
Change this
$('.Page').fadeOut();
$('.page'+divIndex).fadeIn();
To
$('.Page').hide();
$('.page'+divIndex).show();
In your listing page
<!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=utf-8" />
<title>Gallery Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<label for="filterBox">Box1</label>
<select name="filterBox" id="filterBox">
<option value="">- Select -</option>
<option value="Windows">Windows</option>
<option value="Linux">Linux</option>
</select><br />
<div class="filterResults">
<h1>Windows</h1>
<h1>Linux</h1>
</div>
<script type="text/javascript">
$(function(){
$('#filterBox').change(function(){
var Value=$(this).val();
$.post('filter.php', {selectedValue: Value}, function(data) {
if(data) $('.filterResults').html(data);
else location.reload();
});
});
});
</script>
</body>
</html>
In filter.php
<?php
if($_REQUEST['selectedValue']) {
//here print the datas from database related to the selected value
echo '<h1>'.$_REQUEST['selectedValue'].'</h1>';
}
?>
Try This
<!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=utf-8" />
<title>Gallery Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<label for="box1">Box1</label>
<select name="box1" id="box1">
<option value="1">number</option>
<option value="2">letter</option>
</select><br />
<label for="box2">Box2</label>
<select name="box2" id="box2">
<option value="">-- Select Value --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><br />
<label for="box3">Box3</label>
<select name="box3" id="box3">
<option value="">-- Select Value --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<script type="text/javascript">
$(function(){
var Numbers='<option value="">-- Select Value --</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option>';
var Letters='<option value="">-- Select Value --</option><option value="1">a</option><option value="2">b</option><option value="3">c</option><option value="4">d</option>';
$('#box1').change(function(){
var Value=$(this).val();
if(Value==1) {
$('#box2').html(Numbers);
$('#box3').html(Numbers);
}
else if(Value==2) {
$('#box2').html(Letters);
$('#box3').html(Letters);
}
});
$('#box2').change(function() {
var sel = $(this);
$("#box2 option").each(function(){
$("#box3 option[value=" + $(this).val() + "]").show();
});
$("#box3 option[value=" + sel.val() + "]").hide();
});
});
</script>
</body>
</html>
<?php
// If
$search_exploded = array('searchValue1','searchValue2','searchValue3'); // this means $search_exploded[0]=searchValue1;$search_exploded[1]=searchValue2;$search_exploded[2]=searchValue3
$construct="";
foreach($search_exploded as $x=>$search_each)
{
//$x -> index of an array; Here 0,1,2
//$search_each -> Value of array ; hear 'searchValue1','searchValue2','searchValue3'
$x++;
if($x==1)
$construct .="keywords LIKE '%$search_each%'";
else
$construct .=" AND keywords LIKE '%$search_each%'";
}
echo $construct; // Output is =>keywords LIKE '%searchValue1%' AND keywords LIKE '%searchValue2%' AND keywords LIKE '%searchValue3%'
?>
Change this
$dob= $_POST['dob'];
to
if(isset($_POST['dob'])) $dob = $_POST['dob'];
$dob = 'xx/xx/xxxx';
Use Jquery ..
Try this ..
Exg:
<!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=utf-8" />
<title>Gallery Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<a href="#page1" class="link" rel="1">pic1</a>
<a href="#page2" class="link" rel="2">pic2</a>
<div class="Page page1" style="display: none;">
<h1>Gallery-1</h1>
</div>
<div class="Page page2" style="display: none;">
<h1>Gallery-2</h1>
</div>
<script type="text/javascript">
$(function(){
$('.link').click(function() {
var divIndex = $(this).attr('rel');
$('.Page').fadeOut();
$('.page'+divIndex).fadeIn();
});
});
</script>
</body>
</html>
Try this
<?php
$urls="list.txt";
$page = join("",file("$urls"));
$kw = explode("|", $page);
$count=0;
$arrayRow=0;
$links = array();
$images = array();
$widths = array();
$heights = array();
foreach($kw as $key=>$vl) {
$count++;
if ($count==1) $links[$arrayRow] = $vl;
if ($count==2) $images[$arrayRow] = $vl;
if ($count==3) $widths[$arrayRow] = $vl;
if ($count==4){
$heights[$arrayRow] = $vl;
$count = 0;
$arrayRow++;
}
}
?>
Try this
http://code.google.com/p/dompdf/
include_once("dompdf/dompdf_config.inc.php");
$dompdf= new DOMPDF();
if(isset($_REQUEST['txtContent'])){
$content='';
$content.='<!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>
</head><html><body>';
$content.=$_REQUEST['txtContent'];
$content.='</body></html>';
if(empty($content)) {
$error="Please enter contents";
}
else {
$fileName=$_REQUEST['fileName'].'.pdf';
$dompdf->load_html($content);
$dompdf->render();
$dompdf->set_paper(array(0,0,900,800));
$dompdf->stream($fileName);
}
}
Try this
<?php
class myClass
{
public $str;
private $pinCode = 111;
function printPrivateVariable()
{
echo $this->pinCode;
}
}
//object
$ob = new myClass();
$ob -> str = "This is a string.";
//code before the exception
echo $ob -> str.'<br />';
if($ob -> printPrivateVariable())
{
throw new Exception("this is private variable");
}
try
{
echo $ob -> printPrivateVariable().'<br />';
}
catch(Exception $e)
{
echo 'Message : ' .$e -> getMessage().'<br />';
}
//code after the exception
$name = "abc <br />";
echo $name;
?>
You can use different methodes for generating transactionreference Id and OrderId.
I prefer, create those id's related to your order table insert id
First you check, is posted file exist or not
EXg:
$yourFile = "uploads/".$_POST['selectBoxName'];
$checkFile = fopen($yourFile, 'w') or die("can't open file");
fclose($checkFile);
If file exist, then
unlink($yourFile);
Use post method for form submission.
In your form, set
print '<select name="colour[]" multiple="multiple">';
In your action page, set
$csel = array();
$csel = $_POST['colour'];
foreach($colours as $colour => $cname){
$sel = '';
foreach ($csel as $clr) {
if($clr == $colour){
$sel = 'selected="selected"';
}
}
print '<option value="'.$colour.'" '.$sel.'>'.$cname.'</option>';
}
Select options with Pressing Ctrl-button
OR
Select options by click and drag the pointer
Change this
print '<option value="'.$colour.''.$sel.'>'.$cname.'</option>';
to
print '<option value="'.$colour.'" '.$sel.'>'.$cname.'</option>';
First you save the user_id, action_type (IN or OUT) and current_time of user on table.
Then check last action type of that user.
If last action_type is IN , show punch out button, else show punch in button.
1; Set user type for user , ie , if type=0 -> admin user , and type=1 -> normal user
2; When a user login your site, check type of user and save it in a session variable.
3; Check the value of session variable, when each page load and set permission related to the value of session variable
Make sure that , field names country_id and product_id are same as country_wise_products table fields..
Check this
<?php
if (isset($_POST['Submit'])) {
$pro_name = $_POST['product_name'];
$pro_reg_date = $_POST['regstr_date'];
$renewal_date = $_POST['renewal_date'];
$product_shelf = $_POST['pro_shelf_life'];
$countries = $_POST['country'];
$Id=(@mysql_result(@mysql_query("SELECT max(product_id) from products"),0,0)+1);
$c_Id=(@mysql_result(@mysql_query("SELECT max(country_id) from country"),0,0)+1);
$c_w_id = (@mysql_result(@mysql_query("SELECT max(c_w_p_id) from country_wise_products"),0,0)+1);
$sql1 = "INSERT INTO products (product_id, product_name, pro_regt_date, pro_renew_date, product_shelf_life) VALUES
('$Id', '$pro_name', '$pro_reg_date', '$renewal_date', '$product_shelf')";
$sql1_result = mysql_query($sql1) or die (mysql_error());
if(isset($_POST['country'])) {
$cLists = array();
$cLists = $_POST['country'];
$product_id = $Id;
foreach($cLists as $country_id) {
$query = "INSERT INTO country_wise_products (coutry_id, product_id) VALUES ($country_id, $product_id)";
mysql_query($query);
}
}
}
?>
<!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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form name="pro_reg_form" id="form1" method="post" action="">
<table width="40%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td colspan="2">Product Regisration Tracker</td>
</tr>
<tr>
<td>Product Name </td>
<td><input name="product_name" type="text" id="product_name" /></td>
</tr>
<tr>
<td>Product Regsiterd Date </td>
<td><input name="regstr_date" type="text" id="regstr_date" /></td>
</tr>
<tr>
<td>Product Renewal Date </td>
<td><input name="renewal_date" type="text" id="renewal_date" /></td>
</tr>
<tr>
<td>Product Shelf Life </td>
<td><input name="pro_shelf_life" type="text" id="pro_shelf_life" /></td>
</tr>
<tr>
<td valign="top">Country</td>
<?php $stqry = "select * from country order by country_name";
$cat_rs = mysql_query($stqry); ?>
<td><select name="country[]" multiple="multiple" id="country">
<?php
while ($cat_row = @mysql_fetch_object($cat_rs)) {
echo "<option value='".$cat_row->country_id."'>".$cat_row->country_name."</option>";
}?>
</select>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Register" /></td>
</tr>
</table>
</form>
</body>
</html>