473,583 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP beginner question

Ben
Hello,

I am currently learning PHP, and I have a problem with some variables.
On the first page (choix.php), there is a form that lists product
categories.This is the concerned part:

echo "<form action='dc.php' method='post'>
<select name='p_type2' value='p_type2' > \n";

while ($ligne = mysql_fetch_arr ay($result))
{ extract($ligne) ;
echo "<option value='$p_type2 '>$p_type\n";
}
echo "</select>\n";

echo "<input type='submit'".
"value=\"Choisi ssez un type de produit\"></form>\n";?>

On the other page, dc.php , the program has to list the products in
the category chosen by the user above. I want the product chosen to be
inserted in

$typeproduit = "$HTTP_POST_VAR S[$p_type2]";

where $type_produit is the product chosen. (When i write, for
example,:

$type_produit = "CPU";

the program works. But it doesn't work when I put a variable. Can you
help me ?

Thank you
Ben C.
Jul 17 '05 #1
5 1939
Ben wrote:

[snip]
$typeproduit = "$HTTP_POST_VAR S[$p_type2]";


Try:
$typeproduit = $HTTP_POST_VARS[$p_type2];

--
MeerKat

Jul 17 '05 #2
On 23 Sep 2003 13:40:14 -0700, mi******@hotmai l.com (Ben) wrote:
<select name='p_type2' value='p_type2' > \n";
The select element does not have a value attribute.
while ($ligne = mysql_fetch_arr ay($result))
{ extract($ligne) ;
echo "<option value='$p_type2 '>$p_type\n";
}
echo "</select>\n";

echo "<input type='submit'".
"value=\"Choisi ssez un type de produit\"></form>\n";?>

On the other page, dc.php , the program has to list the products in
the category chosen by the user above. I want the product chosen to be
inserted in

$typeproduit = "$HTTP_POST_VAR S[$p_type2]";


$typeproduit = $_POST['p_type2'];

--
Andy Hassall (an**@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
Ben
Andy Hassall <an**@andyh.co. uk> wrote in message news:<vd******* *************** **********@4ax. com>...
On 23 Sep 2003 13:40:14 -0700, mi******@hotmai l.com (Ben) wrote:
<select name='p_type2' value='p_type2' > \n";


The select element does not have a value attribute.


You mean I should remove the value='p_type2' > /n"; ?
or should I put another value ?

Thank you for your answers guys.
Jul 17 '05 #4
Ben wrote:
Andy Hassall <an**@andyh.co. uk> wrote in message news:<vd******* *************** **********@4ax. com>...
On 23 Sep 2003 13:40:14 -0700, mi******@hotmai l.com (Ben) wrote:
> <select name='p_type2' value='p_type2' > \n";


The select element does not have a value attribute.


You mean I should remove the value='p_type2' > /n"; ?
or should I put another value ?


You should remove the value attribute from the select

AFAIK the select construct is like this:

<select name="combo">
<option value="v1">text 1</option>
<option value="v2">text 2</option>
<!-- ... -->
<option value="vn">text n</option>
</select>

And you check it in php with $_POST['combo'] or $_GET['combo']
according to the method used for the form.

The text1, text2, ..., textn are only visible to the browser; you will
not have access to them in the script the form is submitted to --
often they are the same as the v1, v2, ..., vn but that is not
mandatory.
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #5
I noticed that Message-ID: <5h************ *************** *****@4ax.com>
from Pedro contained the following:
<select name="combo">
<option value="v1">text 1</option>
<option value="v2">text 2</option>
<!-- ... -->
<option value="vn">text n</option>
</select>

And you check it in php with $_POST['combo'] or $_GET['combo']
according to the method used for the form.

The text1, text2, ..., textn are only visible to the browser; you will
not have access to them in the script the form is submitted to --
often they are the same as the v1, v2, ..., vn but that is not
mandatory.


But if you leave out the value="", text1, text2 etc become the values.
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2547
by: Svens | last post by:
Hey everyone! I'm a math student working on a short script involving logs. I have a function on my scientific calculator, and was wondering if there was a similar funtion in python. For example: (log65536)/(log4)= 8 I've searched around a bit and haven't been able to find anything.
3
2974
by: jvax | last post by:
Hi all, I hope I'm posting in the right NG... I have a data text file I want to read from a c++ program. the data file goes like this: 90 # number of balls 33 42 13
1
2603
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am experimenting a bit with what I need to do this and have the following code snippet. But first if I pass the assembly name and type to...
14
2284
by: z_learning_tester | last post by:
But I can't seem to find the answer. The question is how do you reverse the words in a string? Or how do you reverse the numbers listed in a string? The example is usually something like: Turn this string "1,2,3,4,..." Into "...4,3,2,1" This one seems hard enough let alone trying to turn a string of space-seperated words around(is that...
12
1876
by: Blaze | last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book to learn a little about programming. I am having issues with the first tutorial not running correctly. It seems that the build fails with what the book tells me to do. Specifically, I am doing this: public authors1 GetAuthors() { authors1 authors = new...
5
2228
by: optimistx | last post by:
As a beginner in javascript I had a question. I was reading FAQ and posts here. I became very unhappy: Obviously this group is mainly for wise, pedantic, unkind etc people, who already know everything about javascript, and want to prove that to everyone in a very harsh way? Therefore, I skip the question, and we can go directly to the...
10
4441
by: Roman Zeilinger | last post by:
Hi I have a beginner question concerning fscanf. First I had a text file which just contained some hex numbers: 0C100012 0C100012 ....
4
1534
by: a | last post by:
Dear all vb.net developer I want to know the time I need to master vb.net? I'm beginner
3
2033
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but might have gotten the syntax wrong. the variable I want to write is a line from a file I am reading: "... f = open('receptor.mol2', 'r') line =...
2
1840
by: roanhn | last post by:
Hello. I've to to write a master's thesis. Currently I deal with php, mysql, ajax. Fate decreed that I've to choose one of this subjects: 1.gdi+ library in .net technology 2.ado.net technology in VS 2008. I didn't have contact with Visual Studio, .NET. I only know some basics of c++. My question is what subject of your point of view...
0
8189
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8198
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6587
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5379
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.