Page 1 of 1
Query is giving 12 duplicates when ran
Posted: Fri Jan 13, 2006 8:02 pm
by Extremest
This query is giving me 12 of each name yet the company is different on each of the duplicates. Can someone tell me where I am screwing up with it.
Each table is made up like this
products = idproducts,name,category,distributor,qty,minqty.
Distributors = iddistributors,company,contact,phone.
select name,qty,minqty,company from `products`, `distributors` where category = '1'
Posted: Fri Jan 13, 2006 8:58 pm
by feyd
it's a side effect from using inner join (the default of a multi-table select)
am I right in guessing that products.distributor is distributors.iddistributors ? If so, tell them to match each other in the where clause.
Posted: Fri Jan 13, 2006 9:14 pm
by Extremest
ok thanks will try that. Have another question. Is there a way to have one form and depending on what they pick it will open a different page on the submit. Instead of just one page.
Posted: Fri Jan 13, 2006 9:16 pm
by hawleyjr
Yes just use Javascript
Code: Select all
function whenTheForIsSubmitted(){
if(document.formName.fieldName.value == 'someValue')
document.formName.action = 'somepage.php';
else
document.formName.action = 'someotherpage.php';
}
Posted: Fri Jan 13, 2006 9:18 pm
by Extremest
ok I have no knowledge of java or javascript. How do I setup the form can I use the form I already have? If so how do I add that to the form?
Posted: Fri Jan 13, 2006 9:20 pm
by hawleyjr
Yes, you should be able to use the form you already have.
Go ahead and post it and I'll show you off of that.
Posted: Fri Jan 13, 2006 9:29 pm
by Extremest
I don't have it complete yet but here it is.
Code: Select all
<form action="lookup.php" method="post">
<select name = "query">
<option>Products by Cat.</option>
<option>View Distributors</option>
<option>View Categories</option>
<option>Get Order</option>
<option>View Schnapps</option>
<option>View </option>
<option>Get Order</option>
<option>Get Order</option>
<input type="submit" value="Submit">
</select>
</form>
Posted: Fri Jan 13, 2006 9:29 pm
by RobertGonzalez
You could also use the PHP page that you are posting to choose which page to show based on the user input:
Code: Select all
<?php
if (isset($_POST['user_choice']))
{
if ($_POST['user_choice'] == 'this')
{
// Show THIS page
}
elseif ($_POST['user_choice'] == 'that')
{
// Show THAT page
}
else
{
// Show the other page
}
}
?>
Posted: Fri Jan 13, 2006 9:32 pm
by Extremest
I was going to try and do that but don't know how to have it open the new page that it would need.
Posted: Fri Jan 13, 2006 9:34 pm
by hawleyjr
PHP is your better bet. Search for the header function or redirect here in the forum. We have plenty of examples.

Posted: Fri Jan 13, 2006 9:50 pm
by Extremest
Thank you very much. That worked out perfect now to finish up some of my code.
Posted: Fri Jan 13, 2006 9:50 pm
by RobertGonzalez
Does the process need to actually open and entirely new page or can it select a different included portion of the page to load. If it just a matter of showing HTML1, HTML 2, etc you can build the HTML modules and depending on the user selection include what they want.
If it's a matter of processing you can still do that, just handle the processing within the scope of the if...elseif...else brackets.
Posted: Fri Jan 13, 2006 10:12 pm
by Extremest
It has to open a completely different page. I am using a switch to check the value of the form and then redirecting to the page I need or executing the query I need. Will work it all out gradually but so far the inventory site I am working on for my bar is working pretty good.