i would like to create form with drop down list that retrieve data from dtadbase
once and other page containg radio bottons but use information that saved in database - <?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Prac 3 Task 4</title>
-
</head>
-
<body>
-
<?php
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql = "SELECT lastName ROM ocustomer ";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<form id="customerform" action="task10.php" method="get">
-
<select name='class' size='1' >
-
<option value='$cusID'>$lName</option>
-
</select>
-
<?php
-
while (odbc_fetch_array($sql))
-
{
-
$cusID = odbc_result($rs,"customerID");
-
$lName = odbc_result($rs, "lastName");
-
echo "";
-
}
-
odbc_close($conn);
-
?>
-
<p><input type="submit" value="Submit">
-
<input type="reset" value="Reset"></p>
-
</form>
-
</body>
-
</html>
plz help
25 2239
hey
You have to put "<option > </option>" inside the while loop .. hav echang ethe code bellow - <?php
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql = "SELECT lastName ROM ocustomer ";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<form id="customerform" action="task10.php" method="get">
-
<select name='class' size='1' >
-
-
-
<?php
-
while (odbc_fetch_array($sql))
-
{
-
$cusID = odbc_result($rs,"customerID");
-
$lName = odbc_result($rs, "lastName");
-
?>
-
<option value='<? echo $cusID; ?>'><? echo $lName; ?></option>
-
<?
-
}
-
-
</select>
-
odbc_close($conn);
-
?>
-
<p><input type="submit" value="Submit">
-
<input type="reset" value="Reset"></p>
-
</form>
good luck
its working but i would like to retrieve information when i submit the form i cant i dont noe why - <?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Prac 3 Task 4</title>
-
</head>
-
<body>
-
<?php
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql = "SELECT lastName FROM customer ";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<form id="customerform" action="task10.php" method="get">
-
<select name='class' size='1' >
-
<?php
-
while (odbc_fetch_array($rs))
-
{
-
$cusID = odbc_result($rs,"customerID");
-
$lName = odbc_result($rs, "lastName");
-
?>
-
<option value='<?php echo $cusID; ?>'><?php echo $lName; ?></option>
-
<?php
-
}
-
-
odbc_close($conn);
-
?>
-
</select>
-
<p><input type="submit" value="Submit">
-
<input type="reset" value="Reset"></p>
-
</form>
-
</body>
-
</html>
-
then goes to this page to get information but it doesnt work
-
<?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Task 10 PHP</title>
-
</head>
-
-
<body>
-
<?php
-
$cusID = $_GET["custID"];
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$cusID'";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<table border="1" summary="product Details">
-
<tr>
-
<th>Order NO</th>
-
<th>Order date </th>
-
<th>Shipped</th>
-
</tr>
-
<?php
-
if (odbc_num_rows($rs)>0) { // Got some data?
-
while (odbc_fetch_row($rs))
-
{
-
$orderNo = odbc_result($rs,"orderNumber");
-
$orderdate = odbc_result($rs, "orderDate");
-
$shipped = odbc_result($rs,"shipped");
-
echo "<tr><td>$orderNo</td>";
-
echo "<td> $orderdate</td>";
-
echo "<td> $shipped</td></tr>";
-
-
}
-
-
}
-
-
else {
-
-
// Display an error message if no data was retrieved or some other error condition was encountered.
-
-
print "<p>There's no values for the customer id please try again: $cusID.</p>";
-
print "<p><a href=\"task10.htm\">Return to try another number.</a></p>";
-
-
}
-
odbc_close($conn);
-
?>
-
</body>
-
</html>
thanks alot for help i appreciate it
thats great.. you are welcome ...
what about the revealing information from first page to next page and i dont know how to link them to show information that customer order
thanks
page one customer.php
we are using $_GET method in the <form > to send those variables to the customer_details.php page using -
<?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Prac 3 Task 4</title>
-
</head>
-
<body>
-
<?php
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql = "SELECT lastName FROM customer ";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<form id="customerform" action="customer_details.php" method="GET">
-
<select name='class' size='1' >
-
<?php
-
while (odbc_fetch_array($rs))
-
{
-
$cusID = odbc_result($rs,"customerID");
-
$lName = odbc_result($rs, "lastName");
-
?>
-
<option value='<?php echo $cusID; ?>'><?php echo $lName; ?></option>
-
<?php
-
}
-
-
odbc_close($conn);
-
?>
-
</select>
-
<p><input type="submit" value="Submit">
-
<input type="reset" value="Reset"></p>
-
</form>
-
</body>
-
</html>
page tow customer_details.php . you could chabge the pagename what evr you want.
we get back posted variables frm here $variable = $_GET["namefild_ofthe_tag"] -
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Task 10 PHP</title>
-
</head>
-
-
<body>
-
<?php
-
$cusID = $_GET["custID"];
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$cusID'";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<table border="1" summary="product Details">
-
<tr>
-
<th>Order NO</th>
-
<th>Order date </th>
-
<th>Shipped</th>
-
</tr>
-
<?php
-
if (odbc_num_rows($rs)>0) { // Got some data?
-
while (odbc_fetch_row($rs))
-
{
-
$orderNo = odbc_result($rs,"orderNumber");
-
$orderdate = odbc_result($rs, "orderDate");
-
$shipped = odbc_result($rs,"shipped");
-
echo "<tr><td>$orderNo</td>";
-
echo "<td> $orderdate</td>";
-
echo "<td> $shipped</td></tr>";
-
-
}
-
-
}
-
-
else {
-
-
// Display an error message if no data was retrieved or some other error condition was encountered.
-
-
print "<p>There's no values for the customer id please try again: $cusID.</p>";
-
print "<p><a href=\"task10.htm\">Return to try another number.</a></p>";
-
-
}
-
odbc_close($conn);
-
?>
-
</body>
-
</html>
-
It should wrk fine, if doesnt wrk give me a buzz ..
it doesnt work because the error says custID undifiend and i cant change custID because its related to html form to recieve information through ID
thanks
thats what i need to do when customer go to page id then its goes to order detail or customer view page with thier name then again its goes to order detail the first two pages work but the other two dont because (custID in order details is undefined into customer page names) please help
the above codes that what i have
if you select one custID and wanna go to different pages to for this customer information then you have to define every time custID to different pages.
you could define custID in different way
1. assign custID as a hidden field when goes to other page
2. pass custID as query string and get custID frm the next page
$custID= $_get['custID'];
3. could assign as a $_session to define custID from different page
and when customer come back to select another custID then old session die and reassign new custID
but i would suggest to assign custID in query string or hidden field
until select a new custID old first time selected custID would be passed in different pages and would be defined first and then get data of that custID.
that how should work.. if you need more help just buzz..
im new to php i dont know how to do hidden fields or query string
thanks again
@lolodede
hidden fields are easy just place the next code somewhere in your form -
<input type="hidden" value="<?php echo $custID; ?>"/>
-
placing custID in a session isn't hard either: -
$_SESSION['custID'] = $custID;
-
after that, you can simply get it on every page with $_SESSION['custID'] but you'll have to start a session. therefor add this code on top of every page: -
is(!isset($_SESSION))
-
session_start()
-
the idea of query string will cost you a lot of work to implement but it's certainly one of the best ways. you'll have to change every href to this. -
<a href="my/path/to/page.php?cusID=<?php echo $_GET['custID']; ?>">my link</a>
-
ofter that, you can use $_GET['custID'] on every page
sorry again but its not working im realy getting confused wat im missing its same error again and again custID undefined ive tried different things but not working id not know what to do
thanks
can you post your code (don't forget to use code-tags) then ill see what i can find
first page -
<?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Prac3 Task 10</title>
-
</head>
-
<body>
-
<h1>Task 10</h1>
-
<form id="customerform" action="task10.php" method="get">
-
<p>please fill in the following form</p>
-
<p>Customer ID: <input type="text" name="custID"/><br/>
-
<p><input type="submit" value="Submit">
-
<input type="reset" value="Reset"></p>
-
</form>
-
</body>
-
</html>
-
second page - <?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Task 10 PHP</title>
-
</head>
-
-
<body>
-
<?php
-
session_start();
-
$cusID = $_GET["custID"];
-
$_SESSION["who"] = $cusID;
-
?>
-
<?php
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$cusID' ORDER BY orderDate ASC";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<table border="1" summary="product Details">
-
<tr>
-
<th>Order NO</th>
-
<th>Order date </th>
-
<th>Shipped</th>
-
</tr>
-
<?php
-
if (odbc_num_rows($rs)>0) { // Got some data?
-
while (odbc_fetch_row($rs))
-
{
-
$orderNo = odbc_result($rs,"orderNumber");
-
$orderdate = odbc_result($rs, "orderDate");
-
$shipped = odbc_result($rs,"shipped");
-
echo "<tr><td>$orderNo</td>";
-
echo "<td> $orderdate</td>";
-
echo "<td> $shipped</td></tr>";
-
-
}
-
-
}
-
-
else {
-
-
// Display an error message if no data was retrieved or some other error condition was encountered.
-
-
print "<p>There's no values for the customer id please try again: $cusID.</p>";
-
print "<p><a href=\"task10.htm\">Return to try another number.</a></p>";
-
-
}
-
odbc_close($conn);
-
?>
-
</body>
-
</html>
-
third page -
<?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>Prac 3 Task 4</title>
-
</head>
-
<body>
-
<?php
-
session_start();
-
$cusID = $_SESSION["who"];
-
?>
-
<?php
-
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
-
$sql = "SELECT lastName FROM customer ";
-
$rs = odbc_exec($conn,$sql);
-
?>
-
<form id="customerform" action="task10.php" method="get">
-
<input type="hidden" value="<?php echo $custID; ?>"/>
-
<select name='class' size='1' >
-
<?php
-
while (odbc_fetch_array($rs))
-
{
-
$cusID = odbc_result($rs,"customerID");
-
$lName = odbc_result($rs, "lastName");
-
?>
-
<option value="<?php echo $cusID?>"> <?php echo $lName; ?></option>
-
<?php
-
}
-
odbc_close($conn);
-
?>
-
</select>
-
<p><input type="submit" value="Submit">
-
<input type="reset" value="Reset"></p>
-
</form>
-
</body>
-
</html>
the third page is the problem
- <option value="<?php echo $cusID?>"> <?php echo $lName; ?></option>
on this line? i'm not sure if it causes the problem but you forgot a ; after $cusID
EDIT: it's great to see you use codetags :)
its undefined custID when i submit the third page
ah ok then you have to edit this line i think: - <input type="hidden" value="<?php echo $custID; ?>"/>
to this - <input type="hidden" id="cusID" name="cusID" value="<?php echo $cusID; ?>"/>
after this you can get its value using $_GET['cusID']
sorry but im really confused more its should be working but not it doest i try wat did u said and it doesnt work same error again and again
on what line do you get the error and in which file (second or third)?
the third page when i submit it and if i put ur line into my code there are more errors like undefined cusID before submit and after submit it to task10.php on that page appear undefined error of custID line 12 which is line get
ok i think i know where the problem is. try changing every cusID you can find to custID. do this in all three files
i did this and receive this message Undefined index: custID in task10.php on line 12
can you post the code of task10.php? since you changed a few things i dont know what line 12 is anymore :)
EDIT: just to verify, try putting the next code as first line: - <?php if($_SERVER["REQUEST_METHOD"] == "GET"){?>
and this code at the end of the file: - <?php }else{echo "ERROR!!";}?>
what do you see now?
How accordingly sir....how.....i have clear that i have three database tables like tbl_a, tbl_b, tbl_c & which have corresponding fields a_id,a_name,b_id,b_name,c_id,c_name. In php page there 3 text box for different table input inside on HTML form. I need to input these three tex box value to different table on database tbl_a,tbl_b,tbl_c. so plz give me idea.don't give me confusen answer..if u don't understand my problem then tell me clearly in which part r u not able to understand. plz
Ur help will be appreciated...
to luckysanj: you've already asked this on a different thread. the answer is given there. all you need to do is post your form and write one SQL query for each table in which you want to insert/update a record.
also this thread is ment to answer lolodede's question. so only questions or answers linked to his/her question may be posted here.
please read the posting guidelines
Ok sorry for my mistake to post on other thread.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Don Stefani |
last post by:
Hello,
I have a form that I want to submit "onchange", OK I've got that working, but when the
form submits, I want to pass along a value to a CGI script, as if that value was in a
hidden form...
|
by: DraguVaso |
last post by:
Hi,
In my application, on some given actions while debugging in Visual Studio, I
suddenly get a "System.ComponentModel.Win32Exception was unhandled"
Message="Error creating window handle."...
|
by: Ben |
last post by:
My current project requires me to create part of a form that is
created on the fly. The project consists a list of entries to an
event. The name and address and such is easy. The design is detup so...
|
by: Iain Miller |
last post by:
Now this shouldn't be hard but I've been struggling on the best way as to
how to do this one for a day or 3 so I thought I'd ask the assembled
company.....
I'm writing an application that tracks...
|
by: James Fortune |
last post by:
Here is an example of Access creating a single page PDF file. The
text in the textbox is scaled to fit horizontally into a grey box 100
pixels wide that is fontsize pixels high. Clicking the...
|
by: longtim |
last post by:
I have been having endless difficulty creating reports/queries that
set any relevent parameters from controls in forms.
I am creating an application under access 2003 but will target access...
|
by: Marius Rus |
last post by:
I have an application write in c# and i want to offer to the user to create
himself shortcuts with icons for the main menu items.
I will very much appreciate if will receive an helping hand.
Thank...
|
by: EnglishMan69 |
last post by:
Hello All,
I am using VB2005 Beta 2 in VS 2005 and am running into a small
problem. I need to be able to add a picture box to the main form from
within a thread.
The program goes to a web...
|
by: solargovind |
last post by:
Hi,
I am New to this forum. I need steps that i do in creating subform.
In main form, i have one table fields like vendor,account,due amount,balance amount and Requisition_id which is...
|
by: OxfordConsult |
last post by:
I have a form and it is to creat a 'link' between a project and a company. Creating a record form this table will simply create a record in a databse with the company ID and project ID. Project ID is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |