Q. How to get multiple results from a single column in a recordset using PHP
Hi everyone
Hope someone can help. I have a column called categories and about 5 categories listed. I want to show all products that are listed in say 2 categories. I only have basic php skills so only know how to pass a url value to show the products from 1 category e.g.
Select *
FROM product
WHERE category = colname
$colname = $_GET['category'];
URL...page.php?category=fruit
Questions is how do I get the products from multiple categories to show e.g. all products from categories 'fruit', 'dairy', 'meat'
Your help will be much appreciated as I am getting tired of beating my head against the wall. (should invent a PHP wall pillow and sell it online)
Thanks
$colname1 = $_GET['category1'];
$colname2 = $_GET['category2'];
$colname3 = $_GET['category3'];
Select *
FROM product
WHERE category IN ('$colname1', '$colname2', '$colname3')
>Your help will be much appreciated as I am getting tired of beating my head against the wall
My guess is that you are trying to build a web application without having first learned the basics on PHP and SQL. That's certainly the hard way.
Similar Messages
-
How to get multiple values from the list
I've a list of an item which I queried it from the database. I also created a button that will takes a selected items from the list when it was clicked. I used javabean to get the data from database.
<% // clicked on Select District Button
Vector vselectedDistrict = new Vector();
Vector vdistrictID = new Vector();
String tmpSelectDistrict = "";
tmpSelectDistrict = request.getParameter("bSelectDistrict");
if(tmpSelectDistrict != null)
// get multiple values from the list
String[] selectedDistrict = request.getParameterValues("usrTDistrict");
vselectedDistrict.clear();
vdistrictID.clear();
if((selectedDistrict != null) && (selectedDistrict.length != 0))
for(int i=0;i<selectedDistrict.length;i++)
vselectedDistrict.addElement(selectedDistrict);
vdistrictID = dbaseInfo.getcurrentDistrictID(nstate,vselectedDistrict);
for(int i=0;i<vdistrictID.size();i++)
out.println("district = " + selectedDistrict[i]); out.println("district ID= " + vdistrictID.get(i).toString());
%>
// get vdistrict from the database here......
<select name="usrTDistrict" size="5" multiple>
<% for(int i = 0; i< vdistrict.size(); i++)
%>
<option value="<%=vdistrict.get(i).toString()%>"><%=vdistrict.get(i).toString()%></option>
<%
%>
</select>
<input type="submit" name="bSelectDistrict" value="Select District">
Lets say the item that i selected from the list is 'Xplace' and I clicked on the Select District button,
what I got is this error message:
org.apache.jasper.JasperException: Unable to convert string 'Xplace' to class java.util.Vector for attribute usrTDistrict: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
So where is going wrong and what the message means?. Any help very much appreciated. ThanksThese are just guesses that might hopefully steer you in directions you haven't looked in yet.
I presume you used triangle brackets (< >) to avoid having the Jive Forum think it was the "italics" tag?
Are you certain this: dbaseInfo.getcurrentDistrictID(nstate,vselectedDistrict);
expects a Vector as its second parameter? And returns a Vector?
I don't believe you've shown how you use the javabean, or its code? Perhaps it should be rewritten to accept an array of strings instead of a Vector? -
How to get multiple records from internal table through BDC
PERFORM DYNPRO USING:
'X' 'SAPMM61L' '0500',
' ' 'BDC_OKCODE' '=NEWC',
'X' 'SAPMM61L' '0500',
' ' 'BDC_CURSOR' 'PLPTU-PLWRK(01)',
' ' 'BDC_OKCODE' '=TAKE',
' ' 'PLPTU-PLWRK(01)' '2531'. (2531 is a plant)
This is the recording used to get plant via BDC of MS31.
Using this code i can get only single plant...
If i want to get multiple plants from an internal table,how i can change this code?
Since it is a recording i cant put this code in LOOP..ENDLOOP.
Suggest any method for doing this....
Awaiting for ur reply...Hi,
While recording also record the scroll down button.
The you can place different plant in the BDC using loop and endloop
Regards
Arun -
How to get multiple rows from database table?
hello !
I need to get multiple rows from a OLEDB database table and display them on a table object.
I did "Wrap in subfrom" on the table, set subform of the table to "flowed", and checked "Repeat row for each data item" of Row1 of the table.
But I can get only one row on the table object.
I need your help.
ThanksHi,
best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
Frank -
Can I get multiple sums in a single column based on a "code" I place.
After importing a file of check/debit card activity from my bank, can I 'code' the line items based on tax categories ie Utilities, Medical expenses, Auto expenses, etc. and then get sums for each based on that code I placed in a single column? That would mean multiple sums in a single column based on the code used for each tax related expense. For instance, I would put UT in the column for utilities expenses and MED in the same column if it were a medical expense. I would then want the sum for all items in that column for each item code. Is this possible or do I need to use a different approach to get this information.
My guess is that the SUMIF function may be your friend.
It's well described in the *iWork Formulas and Functions User Guid*e which every user may download from the Help menu.
Yvan KOENIG (VALLAURIS, France) samedi 2 janvier 2010 21:56:39 -
How to get multiple selections from jsp page in my servlet
Hello Everyone,
I've a list that allows users to make multiple selections.
<select name=location multiple="multiple">
<option>
All
</option>
<option>
Hyd
</option>
<option>
Dub
</option>
<option>
Mtv
</option>
</select>I want to get the selections made by user in jsp page from my servlet, selections can be multiple too.
ArrayList locList = new ArrayList();
locList = request.getParameter("location");when I do so, I get compilation error as the request returns string type. How do I then get multiple selections made by the user.
Please let me know.For those kind of basic questions it would help a lot if you just gently consult the javadocs and tutorials.
HttpServletRequest API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]
Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
Coreservlet tutorials: [http://courses.coreservlets.com/Course-Materials/] -
How to get save result from EXECUTE from a dynamic SQL query in another table?
Hi everyone,
I have this query:
declare @query varchar(max) = ''
declare @par varchar(10)
SELECT @par = col1 FROM Set
declare @region varchar(50)
SELECT @region = Region FROM Customer
declare @key int
SELECT @key = CustomerKey FROM Customer
SET @query = 'SELECT CustomerKey FROM Customer where ' + @par + ' = '+ @key+ ' '
EXECUTE (@query)
With this query I want get col1 from SET and compare it to the column Region from Customer. I would like to get the matching CustomerKey for it.
After execution it says commands are executed successfully. But I want to save the result from @query in another table. I looked it up and most people say to use sp_executesql. I tried a few constructions as sampled and I would always get this error:
Msg 214, Level 16, State 2, Procedure sp_executesql, Line 12
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.
So the output should be a list of CustomerKeys in another table.
How can I save the results from EXECUTE into a variable? Then I assume I can INSERT INTO - SELECT in another table.
ThanksCREATE TABLE Customer
(CustomerKey INT , Name NVARCHAR(100));
GO
INSERT dbo.Customer
VALUES ( 1, N'Sam' )
GO
DECLARE @query nvarchar(max) = ''
declare @par varchar(10) = 'Name',
@key varchar(10) = 'Sam'
CREATE TABLE #temp ( CustomerKey INT );
SET @query =
insert #temp
SELECT CustomerKey
FROM Customer
where ' + @par + ' = '''+ @key+ ''' '
PRINT @query
EXEC sp_executesql @query
SELECT *
FROM #temp
DROP TABLE #temp;
DROP TABLE dbo.Customer
Cheers,
Saeid Hasani
Database Consultant
Please feel free to contact me at [email protected] as well as on Twitter and Facebook.
[My Writings on TechNet Wiki] [T-SQL Blog] [Curah!]
[Twitter] [Facebook] [Email] -
How to get accurate results from sql code ?
Hello everybody,
I have a problem with some portion of my code.
I get more results than I specify in the where clause.
Here is the sample code:
c.gl_acct_id between '110'||'-'||'6890'||'-'||'69000'||'-'||'%'
and '110'||'-'||'7000'||'-'||'67999'||'-'||'%'
For some reason I also get the following results back:
110-6910-51001-001, and 110-6910-51003-001 But I don't need the 51001 and 51003. How do I specify in sql what range I really want. I was sure that the code above is correct. I guess not.
I would appreciate any help,
Thanks,
SonyaHave you tried using the query either of the following...
1) c.gl_acct_id between '110-6890-69000-000'
and '110-7000-67999-999'
and c.gl_acct_id not like '110-6910-51001-%'
and c.gl_acct_id not like '110-6910-51003-%'
assuming you have only 3 digits at the end of gl_acct.
2)If you know that your acct_id belongs to only 69000 or 67999
then
(c.gl_acct_id LIKE '110-6890-69000-%' OR
c.gl_acct_id LIKE '110-7000-67999-%' )
Plz. let me know if this not what you are looking for.
thanx
rajkiran
Here is the whole script:
select distinct c.gl_acct_id acct_no,
c.gl_acct_desc,
min(a.local_act_beg_bal) local_act_beg_bal,
sum(b.local_act_mtd_dr_amt) debits,
sum(b.local_act_mtd_cr_amt) credits,
nvl(min(a.local_act_beg_bal),0)+sum(nvl(b.local_act_mtd_dr_amt,0))-
sum(nvl(b.local_act_mtd_cr_amt,0)) end_bal
from gl_acct c, gl_acct_bal a, gl_acct_bal b
where c.org_unit_id = '110'
and b.gl_acct_id = c.gl_acct_id
and a.gl_acct_id = c.gl_acct_id
and c.sum_det_ind = 'D'
and c.gl_acct_class_ind in ( 'A' , 'L' , 'Q' , 'I' , 'E' )
and a.year_no = '2001'--:loyear
and a.period_no = '1'--:loperiod
and ( ( b.year_no = '2001'--:hiyear
and b.period_no between '1'--:loperiod
and'13')-- :hiperiod
and c.gl_acct_id between '110'||'-'||'6890'||'-'||'69000'||'-'||'%'
and '110'||'-'||'7000'||'-'||'67999'||'-'||'%'
group by c.gl_acct_id, c.gl_acct_desc
I want to have ability to specify ranges for gl_accoount.
Thanks,
Sonya -
Hi All,
I am working with SharePoint 2013 designer workflow. we are using office 365.
Our requirement to send email to multiple users, get the user groups from lookup list people and groups column.
But SP designer sending emails to the first user alone.
Please guide me to proceed.
Advance Thanks.
Regards
Jenkins NS
Thanks and Regards Jenkinsfinally I got a solution
Identified a workaround to solve the issue using SharePoint designer.
Step 1
Create a lookup list Example department
Columns
Title (by default) – Single line of text
Users – Person or Group
Emails – Multiple lines of text
hidden the Emails column (go to content type and set the column as hidden)
Create a SharePoint designer Workflow
Start Workflow automatically when an item is created
Also Start Workflow automatically when an item is changed
Workflow Stage 1
Set Emails to current Item: Users
The workflow will get all users email ids and add in the Emails column delimiter as semicolon.
Step 2
Create a custom list to get the email ids and send email
Create a lookup column ex: analysis and refer department list, Allow multiple values
Then Create a SharePoint designer workflow
full details workflow steps please follow below
URL
http://jenkinsblogs.com/2015/04/30/how-to-send-emails-to-multiple-users-from-lookup-list-people-picker-field-using-sharepoint-designer-workflow/
Thanks and Regards Jenkins -
How to get date prompts from one date column
i have a requirement where i have to filter the data between two date prompts. i have only one date column and the date in the prompts shuld be selected by calendar.
i have seen may approaches to do this and i got one where two dummy date columns should be declared in repository and used to define the date prompts.
but using other methods i could not get the calendar option in prompt.
but is there any other way to get the prompts with calndar selection without defining the dummy columns in repository
thanksyou can do that first select the date column you want to use in dashboard prompt then select another column and in the dashboard prompts then open the fx of the date prompt you first selected copy that and paste it in the second column and in the control section click on calender it will work you can use same date column as two prompts with out creating new column.
-
PS CC 2014 how to get better results from refine edge
In the attached image below you will see "Jesus on the cross" which I want to substitute a new background. On the left is a portion of the unselected image and on the right is the best result I can get via refine edge tool. I have tried all the usual methods such as channels, increasing contrats etc but this is the best I can get. The top thorns had the same problem but what you see now is an hour of manual selection. How do I get a better result - why is it that when the rfine edge brush is swept over such it often only produces transparent results?
I am keep working on this problem today.
I tried Particle Analysis, the result is un-repeatable either. But when I decide to find Straight edge direct from source image,without any process,the angle is more repeatable,Max deviation is 0.03-0.06 degree.It seems my process to the image make thing worse.Then I found the algorithm to find straight is something like linear fit : find all the edge points,linear fit and calculate the angle.
So I run my program for images those pixel resolution is 1280*960,the Max deviation is much lower: 0.008 degree.
If I am right,the best resolution to my problem is to change my camera to higher resolution.
Any advises is appreciate! Thank you! -
How to get table result from XML
Hi I am new to XML, I was playing with node, but wasn't successfull
I have XML fragment
DECLARE @XML xml =
<E1EDP01 SEGMENT="1">
<E1EDP19 SEGMENT="1">
<QUALF>002</QUALF>
<IDTNR>A1</IDTNR>
<KTEXT>PRF NUDE MAGIQUE BB MEDIUM M-UP TST</KTEXT>
</E1EDP19>
<E1EDP19 SEGMENT="1">
<QUALF>003</QUALF>
<IDTNR>E1</IDTNR>
</E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
<E1EDP19 SEGMENT="1">
<QUALF>002</QUALF>
<IDTNR>A2</IDTNR>
<KTEXT>PRF NUDE MAGIQUE BB MEDIUM M-UP TST</KTEXT>
</E1EDP19>
<E1EDP19 SEGMENT="1">
<QUALF>003</QUALF>
<IDTNR>E2</IDTNR>
</E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
<E1EDP19 SEGMENT="1">
<QUALF>002</QUALF>
<IDTNR>A3</IDTNR>
<KTEXT>PRF NUDE MAGIQUE BB MEDIUM M-UP TST</KTEXT>
</E1EDP19>
<E1EDP19 SEGMENT="1">
<QUALF>003</QUALF>
<IDTNR>E3</IDTNR>
</E1EDP19>
</E1EDP01>'
and I need to create query, which list all products and his two codes, result should be like this
ProductCode1
ProductCode2
A1
E1
A2
E2
A3
E3
It is visible from XML fragment, how those values are organised in segments......
I tried to use
select PC1.query('./text()')
AS PC1,
PC2.query('./text()')
AS PC2
from @XML.nodes('/E1EDP01/E1EDP19[1]/IDTNR') as PC1(PC1)
CROSS APPLY @XML.nodes('/E1EDP01/E1EDP19[2]/IDTNR') as PC2(PC2)
But it gets all combinations of ProductCode1 and PRoductCode2, somtehing like cross join and result has 9 rows...
Could you help pleaseTry this,
DECLARE @XML xml ='
<E1EDP01 SEGMENT="1">
<E1EDP19 SEGMENT="1">
<QUALF>002</QUALF>
<IDTNR>A1</IDTNR>
<KTEXT>PRF NUDE MAGIQUE BB MEDIUM M-UP TST</KTEXT>
</E1EDP19>
<E1EDP19 SEGMENT="1">
<QUALF>003</QUALF>
<IDTNR>E1</IDTNR>
</E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
<E1EDP19 SEGMENT="1">
<QUALF>002</QUALF>
<IDTNR>A2</IDTNR>
<KTEXT>PRF NUDE MAGIQUE BB MEDIUM M-UP TST</KTEXT>
</E1EDP19>
<E1EDP19 SEGMENT="1">
<QUALF>003</QUALF>
<IDTNR>E2</IDTNR>
</E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
<E1EDP19 SEGMENT="1">
<QUALF>002</QUALF>
<IDTNR>A3</IDTNR>
<KTEXT>PRF NUDE MAGIQUE BB MEDIUM M-UP TST</KTEXT>
</E1EDP19>
<E1EDP19 SEGMENT="1">
<QUALF>003</QUALF>
<IDTNR>E3</IDTNR>
</E1EDP19>
</E1EDP01>'
SET @XML = '<ROOT>' + CAST(@XML AS NVARCHAR(MAX)) + '</ROOT>'
SET @XML = CAST(@XML AS XML)
;WITH CTE AS (
select t.u.value ('QUALF[1]','varchar(10)') as QUALF,
t.u.value ('IDTNR[1]','varchar(30)') as IDTNR,
t.u.value ('KTEXT[1]','varchar(30)') as KTEXT,
t.u.value ('..','varchar(30)') as DESCR
from @XML.nodes('/ROOT/E1EDP01/E1EDP19') t(u)
SELECT [002] AS ProductCode1,[003] AS ProductCode2 FROM (SELECT QUALF,IDTNR,DESCR FROM CTE) X
PIVOT(MAX(IDTNR) FOR QUALF IN ([002],[003])) PVT
Regards, RSingh -
How to get Multiple records from functions
Hi Everyone
Im new to this stuff. Im trying through JCO. As far as the single recordsets like data of customer or article are concerned i get it through an array.
But i wanted to retrieve
1- Whole tables like (all articles)
2- Selected articles. or Customer order details (articles in PO)
That means multiple records in one go.
Later on ill display it in JTables.
Like for the past three days i was googling around. Thought like this ones not for my stomach. Came across this Forum. Thought its worth posting a request.
Here is the code
public String[] KSearch(String Knr) throws Exception{
String[] Result=new String[11];
IFunctionTemplate ftemplate= Con.repository.getFunctionTemplate("SucheKUNDE");
if (ftemplate == null)
throw new Exception("Funktionstemplate nicht gefunden");
JCO.Function function = ftemplate.getFunction();
JCO.ParameterList input = function.getImportParameterList();
input.setValue(Knr,"FieldName");
JCO.Client client = JCO.getClient(Con.conPoolId);
client.execute(function);
JCO.ParameterList output = function.getExportParameterList();
Result[0]=output.getString("NAME");
Result[1]=output.getString("VORNAME");
Result[2]=output.getString("GDATE");
Result[3]=output.getString("TELEFON");
Result[4]=output.getString("MAIL");
Result[5]=output.getString("STRASSE");
Result[6]=output.getString("PLZ");
Result[7]=output.getString("ORT");
Result[8]=output.getString("KONTO");
Result[9]=output.getString("INSTITUT");
Result[10]=output.getString("BLZ");
JCO.releaseClient(client);
return Result;
now instead of a single record what if im expecting a number of records, like what if i need customer over 25. Which means more than one. I have to get in tabular format so that i can display it in JTables.
Hope it a bit illustrative.
Regards
Edited by: Aaron Maleck on Jan 5, 2008 7:35 AMpublic String[] KSearch(String Knr) throws Exception{
String[] Result=new String11;
IFunctionTemplate ftemplate= Con.repository.getFunctionTemplate("SucheKUNDE");
if (ftemplate == null)
throw new Exception("Funktionstemplate nicht gefunden");
JCO.Function function = ftemplate.getFunction();
JCO.ParameterList input = function.getImportParameterList();
input.setValue(Knr,"FieldName");
JCO.Client client = JCO.getClient(Con.conPoolId);
client.execute(function);
// Maybe here you should use a JCO.Table Class to get the //ExportParameters such as
JCO.Table output = function.getTableParameterList().getTable( "tabelname" );
// so you can use setRow() Function to get the information of the //relevant record. such as the 3. Costum
output.setRow(3);// Record Number
Result[0]=output.getString("NAME");
Result[1]=output.getString("VORNAME");
Result[2]=output.getString("GDATE");
Result[3]=output.getString("TELEFON");
Result[4]=output.getString("MAIL");
Result[5]=output.getString("STRASSE");
Result[6]=output.getString("PLZ");
Result[7]=output.getString("ORT");
Result[8]=output.getString("KONTO");
Result[9]=output.getString("INSTITUT");
Result10=output.getString("BLZ");
JCO.releaseClient(client);
return Result;
Iam not sure that works. But you can try it. and reply me to tell if it really works as i think.
Hope helps.
Amao -
How to get multiple values from the db using select
hi all,
i am using oracle 9i database
i created a procedure
create or replace procedure sample_proce
as
to_i varchar2(50)
begin
select to_id into to_i from sample where flag in('y');
dbms_output.put_line('hai'|| to_i);
end;
when i executed this procedure the following error occurred.
error at line 5 fetching too many rows.
but when i execute the select query alone i can able to view all the rows.
how to resolve iti used the following procedure
create or replace procedure sample_proc
as
begin
for s in(select to_id from sample where flag='y')
loop
dbms_output.put_line(s.to_id);
end loop.
end;
it is executed fine. i can able to fetch all the rows.
how to pass all these values into the another procedure.
we usually pass only one value into another procedure, i do no how to pass all the values . please help me.
Thank u. -
How to get numeric result from 'search and replace' string function
hii
i am using search and replace function to get output.my output is of form ' *X0123.3 ' .here i am replacing the term *X01 with space because i need only 23.3 as a result.but i am unable to get that out in the output indicator.i used lot of functions like string to number and so on but i am getting output as zero .can you please suggest me wt to do.i am attaching a copy of my file.
Attachments:
Untitled 1.vi 25 KBYour problem is the fact that you are converting it to an integer, thus loosing the fractional part. You need to use "Fract/Exp String To Number" instead and create a DBL so yor data is 23.3 instead of 23.
You also don't need to manipulate the string if the initial part is of constant lenght. Just use the offset input as in the figure below.
Message Edited by altenbach on 07-31-2006 07:02 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ToDBL.png 2 KB
Maybe you are looking for
-
What used to work just fine, is no longer working... Within the last 2 days, song purchases that were made on my ipod Touch are no longer being transferred when the ipod synchs up. The strange thing is that the songs appear in iTunes --> Store -- Pu
-
Protecting Video from being saved to other formats?
I have some video files that I want to convert to be able to play them on an iPod and an AppleTV. I have tried exporting from QT, FCP, and Compressor and none of them will allow me to export the files. Compressor started the compression and gave an e
-
Dear DBAs, Is there a V$VIEW that maintains information about the node that was used for taking RMAN backup. I have a 3 node RAC database, and would like to know which node db backup was run from? These are OEM scheduled backup jobs. Thanks
-
How to change pdf page in an iframe content automatically
I open a pdf in my web page with <iframe> and the pdf-option for example #page=2 equals week number 2 of a year. How could I change the viewable page as a function of the actual week number of a year (#1 - 52) At the moment my html code looks like: <
-
Why can't I add metadata to my files?
I have uploaded my pictures to an external hard drive then opened the files in bridge to add metadata. When I try, it says, "file cannot be modified". Any ideas on why this happens or how fix it?