Well what i need is that i have a search option in my app. And status selection. Everything work untill: When i press the "muuda" (modify) button next to line. Modify action takec place in seperate file. Now i have to return to original file. Well, if u searched certain line in my app. After returning back i see again all lines not the one i searched. So i need help to create a session of the search input and mySQL query line (bacuse it is a variable and changes if i search and if i select status) So if anyone can help: Thank you so mutch!
Heres the whole code:
Code: Select all
<html><style type="text/css">
<!--
body {
background-image: url();
background-repeat: no-repeat;
}
-->
</style>
<SCRIPT LANGUAGE="Javascript">
<!---
function decision(message, url){
if(confirm(message)) location.href = url;
}
// --->
</SCRIPT>
<body bgcolor="#abcdef">
<table width="250" border="0">
<tr>
<th width="58" scope="col"><form action="loe.php?cmd=kõik" method="post"><input type="hidden" value="kõik"><input type="submit" name="kõik" id="1" value="kõik" style="background:none;border:0;color:#0000cc;text-decoration: underline" /></th></form>
<th width="58" scope="col"><form action="loe.php?cmd=tellitud" method="post"><input type="hidden" value="tellitud"><input type="submit" name="tellitud" id="2" value="tellitud" style="background:none;border:0;color:#0000cc;text-decoration: underline" /></th></form>
<th width="58" scope="col"><form action="loe.php?cmd=helistatud" method="post"><input type="hidden" value="helistatud"><input type="submit" name="helistatud" id="3" value="helistatud" style="background:none;border:0;color:#0000cc;text-decoration: underline" /></th></form>
<th width="58" scope="col"><form action="loe.php?cmd=käes" method="post"><input type="hidden" value="käes"><input type="submit" name="käes" id="4" value="käes" style="background:none;border:0;color:#0000cc;text-decoration: underline" /></th></form>
<th width="58" scope="col"><form action="loe.php?cmd=otsime" method="post"><input type="text" style="background-color:#FFFF99" name="otsi"></th><th width="58" scope="col"><input type="submit" id="4" value="otsi" style="background:none;border:0;color:#0000cc;text-decoration: underline" /></th></form>
<th width="58" scope="col"><form action="loe2.php" method="post"><input type="hidden" value="hanked"><input type="submit" name="Hanked" id="5" value="Hanked" style="background:none;border:0;color:#0000cc;text-decoration: underline" /></th></form>
</tr>
</table>
<?
if ($_GET['cmd']=='otsime')
{
$otsi = $_POST['otsi'];
$vali = "WHERE kood like '%$otsi%' or nimetus like '%$otsi%' or number like '%$otsi%' or komm like '%$otsi%'" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='kõik')
{
$vali= "order by id" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='tellitud')
{
$vali = "WHERE staatus='tellitud'" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='helistatud')
{
$vali = "WHERE staatus='helistatud'" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='käes')
{
$vali = "WHERE staatus='käes'" or die ('Error: ' . mysql_error());
}else {}
?>
<?php
mysql_connect ("localhost", "root", "radikas") or die ('Error: ' . mysql_error());
mysql_select_db ("foral");
//query
$query = mysql_query("SELECT id, date, kood, kogus, nimetus, number, kes, komm, staatus, ladu FROM tellimus $vali");
//display row
while ($row = mysql_fetch_array($query)) {
$id=$row['id'];//take out the id
$kood=$row['kood'];
$nimetus=$row['nimetus'];
$kogus=$row['kogus'];
$number=$row['number'];
$kes=$row['kes'];
$staatus=$row['staatus'];
$alt=$row['ladu'];
if ($row['staatus']=='tellitud')
{
$color = "style=\"background-color:#66CC66\"";
}else if ($row['staatus']=='helistatud')
{
$color = "style=\"background-color:#FFFF99\"";
}else if ($row['staatus']=='käes')
{
$color = "style=\"background-color:#660000\"";
}else {}
echo
'<form action="muuda.php?cmd=change" method="post">'.'<td border="1" size="1"><input name="id" '.$color.' type="text" size="1" value="'.$row['id'].'">'.'<td border="1" size="3"><input name="kood" '.$color.' type="text" size="8" value="'.$row['date'].'">'.'<td border="1" size="3"><input name="kood" '.$color.' type="text" size="23" value="'.$row['kood'].'">'.'<td border="1" size="3"><input name="nimetus" '.$color.' type="text" size="23" value="'.$row['nimetus'].'">'.'<td border="1" size="3"><input name="kogus" '.$color.' type="text" size="3" value="'.$row['kogus'].'">'.'<td border="1" size="3"><input name="number" '.$color.' type="text" size="23" value="'.$row['number'].'">'.'<td border="1" size="3"><input name="kes" '.$color.' type="text" size="8" value="'.$row['kes'].'">'.'<td border="1" size="3"><input name="komm" '.$color.' type="text" size="17" value="'.$row['komm'].'">';
echo '<select name="staatus" title='.$alt.'><option '.$color.' selected>'.$row['staatus'].'</option><option value="" disabled>----------</option><option value="tellitud">Tellitud</option><option value="helistatud">Helistatud</option><option value="käes">käes</option></select>'.' <td border="1" size="3"><A HREF="javascript:decision(\'Kas kustutame rea '.$id.'?\', \'loe.php?cmd=delete&id='.$id.'\')">kustuta</a>'.'<td border="1" size="3"><input type="submit" value="Muuda" style="background:none;border:0;color:#0000cc;text-decoration: underline"/>'.'<br /></form>';}
?>
<?
if ($_GET['cmd']=='delete')
{
$id = $_GET['id'];
mysql_query("DELETE FROM tellimus where id=$id")or die("Delete Error: ".mysql_error());
echo('<meta http-equiv="Refresh" content="1;url=\'loe.php\'">');
}
?>
Code: Select all
<?
if ($_GET['cmd']=='otsime')
{
$otsi = $_POST['otsi'];
$vali = "WHERE kood like '%$otsi%' or nimetus like '%$otsi%' or number like '%$otsi%' or komm like '%$otsi%'" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='kõik')
{
$vali= "order by id" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='tellitud')
{
$vali = "WHERE staatus='tellitud'" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='helistatud')
{
$vali = "WHERE staatus='helistatud'" or die ('Error: ' . mysql_error());
}else if ($_GET['cmd']=='käes')
{
$vali = "WHERE staatus='käes'" or die ('Error: ' . mysql_error());
}else {}
?>