Forum Moderators: coopster
unnecessary, someone always wanders along. I don't completely follow but the variables and values passed in the url are accessible through the $_GET [ca.php.net] superglobal array (search for GET). You can access the vars passed to your page through that array.
*smiles* Bumps aren't necessary*bows head**smiles*
regards,
lost in vars~land
[edited by: jatar_k at 4:26 am (utc) on May 26, 2005]
<form name="trans" id="trans" method="get" action="resultbtla.php" class="formbox1" >
Transaction#: <input name="transaction" type="text" id="transaction5" />
<input name="TransS" type="submit" id="TransS" value="Search" />
</form>
<form name="Year" id="Year" method="get" action="resultybtla.php" class="formbox2">
or Year: <input name="year" type="text" id="Year24" />
<input name="YearS" type="submit" id="YearS" value="Search" />
</form>
<form name="Date" id="Date" method="get" action="resultybtla.php"class="date" >
or Date:
<input name="month" type="text" id="Month4" value="mm" size="2" maxlength="2"/>
<input name="day" type="text" id="Day2" value="dd" size="2" maxlength="2" />
<input name="year" type="text" id="Year2" value="yyyy" size="4" maxlength="4" />
<input type="submit" name="Submit" value="Submit" />
</form>
so explain to me, not in code, what you would like to have happen when each of these are submitted. I see they are all submitted to the same script.
1. date:.....form submits to the resultbtlapage.php.
2. the resultbtlapage.php filters the record set.
3. the resultbtlapage.php displays the filtered records. And displays duplicate records via a repeat region.
4. the resultbtlapage.php inserts the ....transaction record into the transaction form.
5. resultbtlapage.php then submits the transaction form to the resultYbtla.php
6. resutYbtla.php is supposed to display all the records for trans action ....but the original problem of this post comes into play here.
I know alot of this isn't clear ....i'm not a programmer or analyst but i'm highly intrested
regards and thankyou,
lost in var~Land
well, all the links can easily go to the same script to process and display the desired results, makes it easier that way anyway.
alright first thing to know about programming BE LAZY, I think I stole that from Rasmus but I like it.
Make your life easy, no need to complicate things more than they need to be, or already are.
so, first thing, we look at the forms. I like my forms to mirror the tables they are pulling from. You are searching fr tansaciton #, year and year/month/day.
I would suggest each of these be it's own column, split the year into its own as well, if you want to only search on year it makes it a lot easier if it is all by itself.
so, that decided, let's figure out how we are going to figure out which type of search we need to do. Well an east way is to have a hidden value (love those) to tell us. Maybe something like
<input type="hidden" name="stype" value="year">
then change the value for each form, now our script can make some of its decisions based on that variables value. We could easily use a switch case here since there are more than 2 possible values.
switch [php.net] ($_POST['stype']) {
case "year":
echo 'I am doing a search on the year';
break;
case "fulldate":
echo 'I am doing a search on the year/month/day';
break;
case "transnum":
echo 'I am doing a search on the transaction number';
break;
}
this can also incorporate the "allrecords" scenario but since that is just a link that is another lesson. ;)
within each of those 'cases' we need to build our query based on the submitted values and fields.
so our base query could be something like
select * from ourtable where ....
now the where clause is what we need to create. Each where clause will be different for each submitted form so we build it inside each appropriate case. Let's look at the first one (keep in mind I have no idea what the column names or tablenames are)
where transnum=''
this will grab the entered transaction number and use it in the query. So let's grab that
$_POST['transnum'] is the var we need to get and then concatenate it into our query, we can use the same varname in every case so we can run a generic query function call later ;)
$sql = "select * from ourtable where transnum='" . $_POST['transnum'] . "'";
there we go, the second and third would be similar
$sql = "select * from ourtable where year='" . $_POST['year'] . "'";
$sql = "select * from ourtable where year='" . $_POST['year'] . "' and month='" . $_POST['year'] . "' and day='" . $_POST['day'] . "'";
easy stuff, now we need to add that to our switch and then do our query at the end. We will remove our preliminary echo's from the first example.
switch ($_POST['stype']) {
case "year":
$sql = "select * from ourtable where year='" . $_POST['year'] . "'";
break;
case "fulldate":
$sql = "select * from ourtable where year='" . $_POST['year'] . "' and month='" . $_POST['year'] . "' and day='" . $_POST['day'] . "'";
break;
case "transnum":
$sql = "select * from ourtable where transnum='" . $_POST['transnum'] . "'";
break;
}
$query = mysql_query($sql);
we can now use the variable query to grab all the rows using mysql_fetch_array, you can continue the story here
Basics of extracting data from MySQL using PHP [webmasterworld.com]
Help developing MySQL search query [webmasterworld.com]
that should get you going, and not using dreamweaver wouldn't hurt either ;)