urtrivedi 276 Nearly a Posting Virtuoso
<input type=checkbox name=chk1 id=chk1 value='Yes' 
<?php 
   if ($_SESSION['last_data']['chk1']=='Yes')
    echo "checked";
?>   > Check here


<input type=radiobutton name=rad1 id=rad1 value='No' 
<?php 
   if ($_SESSION['last_data']['rad1']=='No')
    echo "checked";
?>   > No


<select name=sel id=sel >
<option value='v1' <?php echo ($_SESSION['last_data']['sel']=='v1'?"selected":"") ?>     > One</option>

<option value='v2' <?php echo ($_SESSION['last_data']['sel']=='v2'?"selected":"") ?>     > Two</option>


<option value='v3' <?php echo ($_SESSION['last_data']['sel']=='v3'?"selected":"") ?>     > Three</option>

</select>
urtrivedi 276 Nearly a Posting Virtuoso

it should not show <br/> is it part of your note

urtrivedi 276 Nearly a Posting Virtuoso

change your main form file like this

<div><?php echo $_GET['message']?> </div>
<form action='mail.php' >
.
.
.

</form>
urtrivedi 276 Nearly a Posting Virtuoso

I will give one example to set value using session

<input type = "text" name="data_nc" id = "data_nc"  size = "30" value='<?php  echo $_SESSION['last_data']['first_form']['data_nc']?>'/>

in your form2.php you must write

$_SESSION['last_data']['first_form']=$_POST;

also start all pages with session_start()

urtrivedi 276 Nearly a Posting Virtuoso

attach mail.php file here using advance editor

urtrivedi 276 Nearly a Posting Virtuoso

You will always find that username or userid or loginid are always unique for that particular website.
If username of your site is not unique (I am sure it is unique) then then you should find another unique column to rate it distinctly.

do not use

rated  LIKE '%$_SESSION[username]%'

instead use

rated  = '$_SESSION[username]'
karthik_ppts commented: useful post +6
urtrivedi 276 Nearly a Posting Virtuoso

better you post your code for at least form 1, that you have written

urtrivedi 276 Nearly a Posting Virtuoso

on display page add function nl2br as shown here

<td><textarea rows="15" style="width: 99%" readonly><?php echo nl2br($row_Recordset1['Notes']); ?></textarea></td>

You should also change way you update note, new line must be between old note and new note

CONCAT_WS( Notes,'\r\n\r\n', %s)
urtrivedi 276 Nearly a Posting Virtuoso

You are displaing link to note, where and how you display note?

<a href="test5.php?Id=<?php echo $row_Recordset1['Id']; ?>" class="submodal"><img src="Images/editnote.png" /></a>
urtrivedi 276 Nearly a Posting Virtuoso

I have removed <html><body>, spaces, new lines from your mail.php, to avoid header erros.

<?php

  //send email

  $from = 'enquiry@webzymes.com';
  $name = $_REQUEST['txtName'] ;
  $subject = $_REQUEST['txtSubject'] ;
  $company = $_REQUEST['txtCompany'] ;
  $number = $_REQUEST['txtNumber'] ;
   $email = $_REQUEST['txtEmail'] ;
  $msg = $_REQUEST['txtarMessage'] ;
  $message= " Name : " .$name." \n Company : ".$company." \n Contact Number :".$number." \n Email : ".$email." \n Message : ".$msg;
 $mailsent= mail("nikita.chandra@webzymes.com", "$subject",
  $message, "From:" . $from);
if($mailsent)
   $msg1="Mail sent succefully";
else
   $msg1="Error occured while sending mail";
 
header("location:contactUs.html?message={$msg1}");
exit;
?>
urtrivedi 276 Nearly a Posting Virtuoso

you must replace $note with variable of your data fetch array

urtrivedi 276 Nearly a Posting Virtuoso

1 removed () around echo
2 merged two lines,
3 changed " to '

echo "<br>You left out some required dields. <STRONG>Record NOT added</STRONG>. Enter this record again, please <P align='center'><A HREF='http://www.kotw.net'><STRONG>Go Back</STRONG></A></P> ";
urtrivedi 276 Nearly a Posting Virtuoso

your form page, say myform.html.

<div><?php echo $_GET['message']?> </div>
<form action='mail.php' >
.
.
.

</form>

your mail.php

<?php
$mailsent=mail('som@g.com','hi','how are you');

if($mailsent)
   $msg="Mail sent succefully";
else
   $msg="Error occured while sending mail";

header("location:myform.html?message={$msg}");
exit;

?>
urtrivedi 276 Nearly a Posting Virtuoso

two lines after note and then add current note

CONCAT_WS( Notes,'\r\n\r\n', %s)

then when you display note in html page. you may use
nl2br function to convert new line to html break
<?php
echo nl2br ($note);
?>

urtrivedi 276 Nearly a Posting Virtuoso
<div><b><a href='edit.php?articleid=1'>My article 1</a> </b>
content 1 content 1 content 1 content 1 content 1
 
</div>


<div><b><a href='edit.php?articleid=2'>My article 2</a> </b>
content 2 content 2 content 2 content 2 content 2
 
</div>

<div><b><a href='edit.php?articleid=3'>My article 3</a> </b>
content 3 content 3 content 3 content 3 content 3
 
</div>
urtrivedi 276 Nearly a Posting Virtuoso
Still a small problem

I am not able to understand your problem.

urtrivedi 276 Nearly a Posting Virtuoso

I have selected only required columns and echoed query before running it.
When you run this page, copy the query output from browser and run it in phpmyadmin, and see what comes as result

<?php
$query="SELECT topics.quizId, topics.title, quiz.passState' FROM topics LEFT JOIN quiz ON topics.managerId = quiz.managerId WHERE quiz.userId = '$userId' AND userId= '$userId' AND $egroup = 1 GROUP BY topics.title";

echo $query;//when you run this page, copy the query output from browser and run it in phpmyadmin, and see what comes as result

$result = mysql_query($query)OR die(mysql_error());
?>
urtrivedi 276 Nearly a Posting Virtuoso

try to do without sprintf,

$notes=addslashes($_POST['Notes']);
$updateSQL = "UPDATE Leads SET Notes = CONCAT_WS(Notes,'\r\n', '{$notes}') WHERE Id='{$_POST['Id']}'";
urtrivedi 276 Nearly a Posting Virtuoso

in your post handler form you check errors

<?php
unset($_SESSION['last_data']);
unset($_SESSION['errors']);
if(errors)
{
//set error session here
$_SESSION['last_data']=$_POST;
}
else
{
//update/insert database
}

header("location:myform.php");
exit;
?>

Now in your main form
you can diplay session errors if session errors is set, and use last data to set back values

<?php
if(isset($_SESSIONS['errors'])
{
//display errorrs at the top of page
}

.
.
.
.
<input type=text name=txt1 id=txt1 value='?php echo  $_SESSION['last_data']['txt1']?>' >
.
.
.
.
?>
AngelicOne commented: Redirecting a form is something new to me using PHP! Thank you very much! +3
urtrivedi 276 Nearly a Posting Virtuoso

Hi almostbob, I overlooked that sentence but this code should work in either way you
want.
anandhikrishnan, here is final code

<html>


<script language="javascript">

	function validate(dt1,dt2)
	{
		
		var jdt1=Date.parse('20 Aug 2000 '+dt1);
		var jdt2=Date.parse('20 Aug 2000 '+dt2);
		
		if(isNaN(jdt1))
		{
			alert('invalid start time');
			return false;
		}
		if(isNaN(jdt2))
		{
			alert('invalid end time');
			return false;
		}
	  	if (jdt1>jdt2)
		{
			alert('start is greater');
		}
		else
		{
			alert('start is less equal');
		}
	
		
	}
	
</script>

<body>
<div>


<form name=frm id=frm action=temp.php method="get" accept="text/csv">
<P>&nbsp;</P>
start <INPUT id=txt1 name=txt1 value='10:30:05 am'>&nbsp; <br>
end <INPUT id=txt2 name=txt2  value='10:40:05 am'>&nbsp; 
<input type=button value=ok id=button2 name=button2 onclick ='validate(document.frm.txt1.value,document.frm.txt2.value)'>&nbsp;&nbsp; 
 </P>
</form></div>
<script language='javascript'>
</script>
<div id="txtHint">&nbsp;
</div>
<P></P>

</body>
</html>
urtrivedi 276 Nearly a Posting Virtuoso
<html>


<script language="javascript">

	function validate(dt1,dt2)
	{
		
		var jdt1=Date.parse('20 Aug 2000 '+dt1);
		var jdt2=Date.parse('20 Aug 2000 '+dt2);
		
	/*	if(jdt1=='NaN')
		{
			alert('invalid start time');
			return false;
		}
		if(jdt2=='NaN')
		{
			alert('invalid end time');
			return false;
		}*/
	  	if (jdt1>jdt2)
		{
			alert('start is greater');
		}
		else
		{
			alert('start is less equal');
		}
	
		
	}
	
</script>

<body>
<div>


<form name=frm id=frm action=temp.php method="get" accept="text/csv">
<P>&nbsp;</P>
start <INPUT id=txt1 name=txt1 value='10:30:05 am'>&nbsp; <br>
end <INPUT id=txt2 name=txt2  value='10:40:05 am'>&nbsp; 
<input type=button value=ok id=button2 name=button2 onclick ='validate(document.frm.txt1.value,document.frm.txt2.value)'>&nbsp;&nbsp; 
 </P>
</form></div>
<script language='javascript'>
</script>
<div id="txtHint">&nbsp;
</div>
<P></P>

</body>
</html>
urtrivedi 276 Nearly a Posting Virtuoso

I assume gid is number

so pass one more parameter test.jsp?gid=1&gidlist=-1,2,3,
track entered ids using javascript store it some where.

then in your query you may write

"select gid, sgg_eng_nm from test where gid not in ($gidlist)"
urtrivedi 276 Nearly a Posting Virtuoso

Explain in detail. post acutally table structure and sample data (preferably in sql format)
Then post expected output.

urtrivedi 276 Nearly a Posting Virtuoso

implode works on array not on string
so you need to replace spaces with hyphen.

I am assuming only one space between all ids

$id1 = str_replace(" ","-", $id);
urtrivedi 276 Nearly a Posting Virtuoso

I have sever browsing code, but you need to find some way that how to select file and copy path to server. also find 2 images below for better view.

<?php



	session_start();
	

	if (trim($_POST['dirname'])=="")
		$currdirectory=dirname($_SERVER['DOCUMENT_ROOT']);
	else
		$currdirectory=$_POST['dirname'];
	$_SESSION['dirname']=$currdirectory;			

	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<script lang=javascript>
	function link_click(dname)
	{
		document.frmdir.dirname.value=dname;
		document.frmdir.submit();
	}
</script>
<BODY>

<?php
	
	$files = scandir($currdirectory);
	print "<b><BR>{$currdirectory}</b><br>";
	
	if (!(substr(strrev(trim($currdirectory)),0,1)=='/' ||substr(strrev(trim($currdirectory)),0,1)=='\\'))

		
	print "<a href=\"javascript:link_click('".str_replace('\\','',dirname($currdirectory))."')\">Up</a><br>";
?>

<?php


	print "<form method='post' name=frmdir id=frmdir action='{$_SERVER['PHP_SELF']}'>";
	print "\n<table border=0>";
	for ($i=0;$i<count($files);$i++)
	{
		
		$content=$currdirectory."/".$files[$i];
	 	
	 	if (is_dir($content) && trim($files[$i])!="." && trim($files[$i])!="..")
	 	{
			print "\n<tr>";	 	 
			print "\n\t<td valign=bottom><img src='./folder.jpg' border=0 >	</td>";
			print "<td><a href=\"javascript:link_click('".$content."')\">{$files[$i]}</td></a>";	 	
	 		print "\n</tr>";
		}

	}

	for ($i=0;$i<count($files);$i++)
	{
		 $content=$currdirectory."/".$files[$i];
	 	if (is_file($content))
	 	{
 			print "\n<tr>";
			print "\n\t<td valign=center align=right><img src='./file.jpg' border=0></td>";	 	 
			print "\n\t<td><span >{$files[$i]}</span>";
	 		print "\n</td></tr>";
		}

	}
	print "\n</table>";
?> 
<input name=dirname id=dirname type=hidden>
</form>


</BODY></HTML>
urtrivedi 276 Nearly a Posting Virtuoso

TRY CHANGE FOLLOWING LINES

LINE 26

$querymain="SELECT substrING(C1.GroupID,1,3) GroupID,

LINE 42

GROUP BY  substrING(C1.GroupID,1,3) ";

LINE 100

where  groupID like '{$rowmain['GroupID']}%'
urtrivedi 276 Nearly a Posting Virtuoso

if database is readonly for you then. there is not alternative, if you can update triagroup column with some data then it could be fine.

But in case of readonly database we do following.

Identify common pattern in groupname. like lets take first 3 character from group name
so hopefully we get ABP, CIB, BAF (not BAFF as we take only 3 chars)
then this way we can expected output.
but are you sure first 3 letters will be our required master groups?

urtrivedi 276 Nearly a Posting Virtuoso

i will say ABP, CIB, BAFF as CATEGORY
and ABP(JUN-2010), BAFF -JUN-JUL-10 AS GROUPID.

in your reg_group table you do not have category, so for precise report, you must add one column to reg_group that is CATEGORY.

groupid, groupname, category
ABP(JUNJUL10), ABP(JUNJUL10), ABP
BAFF-JUL 10, BAFF-JUL 10, BAFF


IF YOU DO NOT WANT TO ADD MORE COLUMN THEN you may use trialgroup column if it is blank. you can add ABP, BAFF in trialgroup column.

Then we have to just modify query at few places.

So tell me what are you going to do now.

urtrivedi 276 Nearly a Posting Virtuoso

HERE IS THE CODE

<html>
<head>
<script lang=javascript>
isEmail1    = /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
isEmail2    = /^.*@[^_]*$/;

function isEmail(s) 
{
  return (isEmail1.test(s) && isEmail2.test(s));
}


function validate(what) {


 if (!isEmail(what.txtemail.value))
 {
    alert('Invalid email id');
    return false;
 }
 else
 {
	  alert('WELCOME ID IS VALID');
}
//return true;
}

</script>
</head>
<body>
<form name=frm id=frm onsubmit='return validate(this);'>
<input type=text name=txtemail id=txtemail >
<input type=submit name=btnsub id=btnsub >
</form>
</body>
</html>
urtrivedi 276 Nearly a Posting Virtuoso

check this

urtrivedi 276 Nearly a Posting Virtuoso

wait this is very poor query. We will get the optimzed one soon.

urtrivedi 276 Nearly a Posting Virtuoso

I was in impression that you are using MYSQL. In MSSQL "if" will not work, we need to change it to "case when then". Ok let me check and I will come back soon.

urtrivedi 276 Nearly a Posting Virtuoso

You mean what is not working.
1) you are not able to delete record now after adding post id in delete.php
2) or you are able to delete record but you are not able to update contentbox
3) or both things not working

urtrivedi 276 Nearly a Posting Virtuoso

copy this and see are you able to run this query in your phpmyadmin, I do not have all data as you so it is not giving any error to me.

urtrivedi 276 Nearly a Posting Virtuoso

echo the query and post its output here

echo $querymain;
$resultmain=mysql_query($querymain);
urtrivedi 276 Nearly a Posting Virtuoso

Use OR very carefully, CRA is applicable in all cases so no need to use it in query.
We must simply find in which case we will need recepitdate then for rest case we will use returndate

find the simplest conditions (only guess cases for returndate) then I will help you more on it.

urtrivedi 276 Nearly a Posting Virtuoso

You please simply run my original e3.php(do not add anything except orgname and mysql login values), it is already formatted in that format. You do not have to worry about query.

PLEASE DO NOT CHANAGE ANYTHING (except orgname and mysql login values).

Here is output(output.jpg) for what you send me in sql file and main php file (e3.txt)(attaching again).

urtrivedi 276 Nearly a Posting Virtuoso

I think we can do that, but making your own browse window. as you find on browser based ftp managers. where user will browse server directories.

Another way we can do is instead of file field, if user knows the file path of file name(in case folder is fixed), give only text box where user will write the file path or name.

urtrivedi 276 Nearly a Posting Virtuoso

Now you have changed the query drastically, Now don't you want output in 12 months columns.
whenever you get error, post output query with your post.

urtrivedi 276 Nearly a Posting Virtuoso

yes you can

urtrivedi 276 Nearly a Posting Virtuoso

I hope you have not changed the code, because it is working here

before this like

$resultsub=mysql_query($querysub);

add one more line it shold look like this

echo $querysub;
 $resultsub=mysql_query($querysub);

post that generated query here

urtrivedi 276 Nearly a Posting Virtuoso

Here is your query

select
ESN ,
 Supplier,
 RType ,
 WarrantyPeriod ,
 TodaysDate ,
 Returndate ,
 Receivedate ,	 
DATEDIFF(day,  case when Supplier ='AC8' OR Supplier ='BEI'THEN  returndate ELSE RECEIVEDATE END, todaysdate) TOTALDAYS,
CASE WHEN DATEDIFF(day,  case when Supplier ='AC8' OR Supplier ='BEI'THEN  returndate ELSE RECEIVEDATE END, todaysdate)<WarrantyPeriod THEN 'YES' else 'N0' END WarrantyDecision 
from mytable
urtrivedi 276 Nearly a Posting Virtuoso

I could not insert partial date if you mysql datatype is date.

Post your code what you have done so far after my suggestion.

urtrivedi 276 Nearly a Posting Virtuoso

source and destination servers are same or different

urtrivedi 276 Nearly a Posting Virtuoso

have you used file i have attached in my previous post.

http://www.daniweb.com/web-development/php/threads/374124/1610733#post1610733

urtrivedi 276 Nearly a Posting Virtuoso

You must quote operators
if (ope=='+')
there no operators function

<html>
<body>
<script lang="text/javascript">

var num1, num2, ope, sum, diff, prod, quo, mod;
num1=Number(prompt("Enter First number: "));
num2=Number(prompt("Enter Second number: "));
ope=prompt("Choose Operator : + - * / %");

if (ope=='+')
{
sum=num1+num2;
document.write("The sum is: "+sum);
}

else if (ope=='-')
{
diff=num1-num2;
document.write("The difference is: "+diff);
}

else if (ope=='*')
{
prod=num1*num2;
document.write("The product is: "+prod);
}

else if (ope=='/')
{
quo=num1/num2;
document.write("The quotient is: "+quo);
}

else if (ope=='%')
{
mod=num1%num2;
document.write("The remainder is: "+mod);
}

else
{
document.write("INVALID!");
}

document.write("<br>First Number: "+num1);
document.write("<br>");
document.write("Second Number: "+num2);
document.write("<br>");
document.write("Operator Used: "+ope);

</script>
</body>
</html>
urtrivedi 276 Nearly a Posting Virtuoso

When you are dealing with date and time, always use datatime datatype. Do not use varchar. You will always able to extract data by month, year, week, day whatever you want using certain functions.


I said anywhere you should use some names for columns and tables other than keyword like select, group, from, order, timestamp, date etc.

It is not related to security, but some time certain queries do not work just due to such colnames.
Though it is not mandatory. In mysql You may wrap such names with ``.
like `timestamp`

urtrivedi 276 Nearly a Posting Virtuoso

if you know the path of the file on server, you may use

readfile('http://server/folder/image.jpg');

urtrivedi 276 Nearly a Posting Virtuoso

As far as I know in mysql by default datatime field is stored in
yyyy-mm-dd format. Though if data is in another format then you may use mysql strtodate (some thing like that) function.

I suggest you to directly use mysql current_timestamp function

mysql_query ("INSERT INTO $tablename (timestamp,name) VALUES (current_timestamp,'$name')");

Note: you should also avoid using keywords as column or table name. Here you may change timestamp column to my_time or any other

urtrivedi 276 Nearly a Posting Virtuoso

You must also consider javascript in mind. load server time in javascript and manage countdown clock there.

http://www.w3schools.com/js/js_timing.asp