*Solved \\PHP Sessions question.
Posted: Fri Jan 22, 2010 10:55 am
Lately iv'e been asking a lot of questions and some of them figured out by myself. But now i face the problem.
Iv'e created database. table looks like this: id, date, kood, nimetus, number, kes, comment, staatus, all. from index i inclused file loe.php.
In loe.php i have this:
Index.php looks like this:
Main thing is: Session is controling the values in loe.php to read out certain line WHERE socalled status=status_from_dropdownmenu.
It works fine, but if i select the value -------- from dropdown. I have no status in mysql with that name "id" under status. Question is: How can i change session value $mis='staatus'; to $mis='id'; using the same dropdown box.
So in plain stubid way:
I could use $_POST status as $mis value but in mysql i need to get the value from either status or id.
Not that my current script aint working but it has a flaw in it. It only shows the column status value if status is selected. But i want to add users a chance to see all lines too not only the lines with selected. AKA i'm making a filter. At the beginning there should be visible all lines from mysql. But when user selects Filter from Dropdown menu, it will show only rows with selected status.
Ok. Confusing. At least for me. So any help? I have been figuring around this for couple of days now. This IS my first project where i use MySQL.
(when i started i user txt files LOL)
Thank's for your responses.
Iv'e created database. table looks like this: id, date, kood, nimetus, number, kes, comment, staatus, all. from index i inclused file loe.php.
In loe.php i have this:
Code: Select all
<?php
session_start();
$miss=$_SESSION['mis'];
$stats=$_SESSION['filter'];
?>
?php
mysql_connect ("localhost", "root", "defender") or die ('Error: ' . mysql_error());
mysql_select_db ("foral");
if(!isset($cmd));
{
//query
$query = mysql_query("SELECT * FROM tellimus WHERE $miss='$stats'");
Code: Select all
<?php
session_start();
if ($_SESSION['filter']=''){
}else {
$mis='staatus';
($filter=$_POST['staatus']);
}
// adds it to our session
$_SESSION['mis']=$mis;
$_SESSION['filter']=$filter;
?>
<form action="index.php" method="post" name="staatus" id="staatus" target="_self">
Kuva ainult ridasid mille staatus on:
<select name="staatus">
<option value="id">----------</option>
<option value="tellitud" value="staatus">Tellitud</option>
<option value="helistatud">Helistatud</option>
<option value="käes">käes</option>
</select>
<input type="submit" name="Submit" value="Submit" />
</form>
It works fine, but if i select the value -------- from dropdown. I have no status in mysql with that name "id" under status. Question is: How can i change session value $mis='staatus'; to $mis='id'; using the same dropdown box.
So in plain stubid way:
Code: Select all
if ($_POST['staatus'] = "tellitud") {
$mis="staatus";
($filter=$_POST['staatus']);
}else if ($_POST['staatus'] = "id") {
$mis="id";
($filter=$_POST['staatus']);
}
I could use $_POST status as $mis value but in mysql i need to get the value from either status or id.
Not that my current script aint working but it has a flaw in it. It only shows the column status value if status is selected. But i want to add users a chance to see all lines too not only the lines with selected. AKA i'm making a filter. At the beginning there should be visible all lines from mysql. But when user selects Filter from Dropdown menu, it will show only rows with selected status.
Ok. Confusing. At least for me. So any help? I have been figuring around this for couple of days now. This IS my first project where i use MySQL.
(when i started i user txt files LOL)
Thank's for your responses.