473,598 Members | 3,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem of variable between two pages

Hi,

On a page, I have a form with a variable number of fields.

to print these fields, I have such a code :
while ($i !=0){
echo '<td> <input type="text" name="component '.$i.'" size="20"
value="" maxlength="70"> </td><br>
<td> <input type="text" name="quantity' .$i.'" size="20"
value="" maxlength="70"> <br>
</td> </tr><tr>' ;
$i = $i - 1 ;
}

I then get variables such as component1, component2, etc. and quantity1,
quantity2, etc.

next page I want to enter these values into a MySQL table.

I am therefore passing from one page to another the value of the variables,
and some others.
I get the following code :
<?
$i = $nombercomponen t ;
$db = mysql_connect(' localhost', '', '');
mysql_select_db ('recipe',$db);
while ($i !=0){
$sql = "INSERT INTO component VALUES('','','$ ingr','$quant') ";
mysql_query($sq l) or die('Error !'.$sql.'<br>'. mysql_error());
$i = $i - 1 ;
}
mysql_close();
?>

How to have $ingr and $quant corresponding to all component and quantity
variable there number is variable ?
Thanks in advance

Philippe
Jul 17 '05 #1
1 1466
In article <c6***********@ biggoron.nerim. net>, Philippe Rousselot wrote:
Hi,

On a page, I have a form with a variable number of fields.

to print these fields, I have such a code :
while ($i !=0){
echo '<td> <input type="text" name="component '.$i.'" size="20"
value="" maxlength="70"> </td><br>
<td> <input type="text" name="quantity' .$i.'" size="20"
value="" maxlength="70"> <br>
</td> </tr><tr>' ;
$i = $i - 1 ;
}

I then get variables such as component1, component2, etc. and quantity1,
quantity2, etc.

next page I want to enter these values into a MySQL table.

I am therefore passing from one page to another the value of the variables,
and some others.
I get the following code :
<?
$i = $nombercomponen t ;
$db = mysql_connect(' localhost', '', '');
mysql_select_db ('recipe',$db);
while ($i !=0){
$sql = "INSERT INTO component VALUES('','','$ ingr','$quant') ";
mysql_query($sq l) or die('Error !'.$sql.'<br>'. mysql_error());
$i = $i - 1 ;
}
mysql_close();
?>

How to have $ingr and $quant corresponding to all component and quantity
variable there number is variable ?


What is the version of php you are using? If you would have bothered to
type in your question in the google search groups box, you would have
found the answer a zillion times. (hint: register globals)

It's probably not a bad idea to perform a mysql_escape_st ring on the
values you are trying to insert into your database.

--
http://home.mysth.be/~timvw
Jul 17 '05 #2

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

Similar topics

1
1895
by: farooqazeem | last post by:
Hi guys, I’m facing some problem can u solve it. Problem is: I’m giving user Id and password in (Login_sess.asp) and submit it to page (sess_test.asp). I am setting session variable (session(“Sin”)=”Yes”) just before redirecting to the same page, but in first time I do not received the value of session variable when I redirect it, when I execute this process second time or redirect it only with the page name...
4
2800
by: Trevor Best | last post by:
I have a report that's fairly simple, page headers and footers, detail has a subreport in (can vary in length). The customer wanted a signature block for them, their client and 3rd party. This was no problem, couple of boxes and labels in the report footer. Now customer wants this signature block on the foot of page 1 (stoopid IMO as that implies people read page 1 where at the end implies they read past page 1 at least). Anyway to...
1
1780
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open the second page using Window.Open with the values being passed to the second page by a global variable created in a Module added to the project, by the use of an Application variable and by the use of a session variable. In the page load of the...
20
8678
by: Hemant Shah | last post by:
Folks, I spent better part of morning debugging a problem and it turned out to be DB2_USE_ALTERNATE_PAGE_CLEANING registry variable. I am running DB2 8.2 on AIX 5.3 system: # oslevel 5.3.0.0
2
2165
by: RoomfulExpress | last post by:
The only problem I'm having with this code is when there are no values returned for the query, it is still allowing you to see and click the 'Next>>'. It disappears when there is at least one return on the search, but when there is none, it shows up. Here is where I got the source code from and of course the forum is 404'd. They're code has the exact same problem as my modified code. http://www.designplace.org/scripts.php?page=1&c_id=25 my...
0
7987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
7899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8392
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8397
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8264
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
2412
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
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.