|
 |
|
Dev Articles Community Forums
> Programming
> PHP Development
|
PHP forms
Discuss PHP forms in the PHP Development forum on Dev Articles. PHP forms PHP Development forum to discuss anything related to developing applications in PHP. Topics include architecture, coding standards, and debugging methods.
|
|
 |
|
|
|
|

Dev Articles Community Forums Sponsor:
|
|
|

February 19th, 2013, 03:58 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 7
Time spent in forums: 33 m 39 sec
Reputation Power: 0
|
|
|
PHP forms
Hello,
I am totally new to php and need a help with solving the followinf problem:
I've got a database file creating 3 tables:
Code:
<?
$db=sqlite_open("../paintings.db");
@sqlite_query($db, "DROP TABLE Picture");
@sqlite_query($db, "DROP TABLE Artist");
@sqlite_query($db, "DROP TABLE Sales");
@sqlite_query($db,"CREATE TABLE Picture( ID integer PRIMARY KEY , name VARCHAR[200], year integer, artistID integer)",$sqliteerror);
@sqlite_query($db,"CREATE TABLE Artist( ID integer PRIMARY KEY , name VARCHAR[200], DOB integer, DOD integer, nationality VARCHAR[200])",$sqliteerror);
@sqlite_query($db,"CREATE TABLE Sales( pictureID integer , date VARCHAR[20], price REAL)",$sqliteerror);
//NB use of ' and "
sqlite_query($db,'INSERT INTO Picture (name, year, artistID) VALUES ( "The Haywain", 1821, 1)');
sqlite_query($db,"INSERT INTO Picture (name, year, artistID) VALUES ( 'Salisbury Cathedral from the Meadows', 1831, 1)");
sqlite_query($db,"INSERT INTO Picture (name, year, artistID) VALUES ( 'A Wheatfield, with Cypresses', 1889, 2)");
sqlite_query($db,"INSERT INTO Artist (name, DOB, DOD, nationality) VALUES ( 'John Constable', 1776, 1837, 'British')");
sqlite_query($db,"INSERT INTO Artist (name, DOB, DOD, nationality) VALUES ( 'Vincent Van Gogh', 1753, 1890, 'Dutch')");
sqlite_query($db,"INSERT INTO Sales VALUES ( 1, '1/9/2008', 23.56)");
sqlite_query($db,"INSERT INTO Sales VALUES ( 1, '9/1/2009', 500230.00)");
sqlite_query($db,"INSERT INTO Sales VALUES ( 3, '15/12/2009', 87.56)");
sqlite_close($db);
?>
What I have to do is:
Create a form that allows the user to input information about another picture for a given artist and then handles this in a different page. The second page shows all the artists in the database.
For the first page try to use a drop down list for the choice of artist for ones that are currently in the database – hint you will need to have a query on the database to select all the artists, then use a for loop to add these to items on a drop down list.
I am so confused, do not really know what I have to do.
I would appreciate any help.
|

February 19th, 2013, 04:01 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 7
Time spent in forums: 33 m 39 sec
Reputation Power: 0
|
|
So far i've done this bit of code that creates a drop down list box with artists in it.
Code:
<html>
<body>
<?php
$db=sqlite_open("../paintings.db");
$result=sqlite_query($db,"SELECT ID, name from Artist");
$options="";
while($row=sqlite_fetch_array($result,SQLITE_ASSOC ))
{
$id=$row["ID"];
$name=$row["name"];
$options.="<OPTION VALUE=\"$id\">".$name.'</option>';
}
sqlite_close($db);
?>
<SELECT NAME=id>
<OPTION VALUE=0>Choose
<?php echo $options ?>
</SELECT>
</body>
</html>
So now I need to have some code that would have textboxes that will allow to insert information about new picture for a given artist and store this information in the database. Any ideas?
|

March 15th, 2013, 05:34 AM
|
|
Registered User
|
|
Join Date: Mar 2013
Location: L.D.A. Colony, Kanpur Road Lucknow, India 226012
Posts: 1
Time spent in forums: 31 m 52 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by GarryBrown So far i've done this bit of code that creates a drop down list box with artists in it.
Code:
<html>
<body>
<?php
$db=sqlite_open("../paintings.db");
$result=sqlite_query($db,"SELECT ID, name from Artist");
$options="";
while($row=sqlite_fetch_array($result,SQLITE_ASSOC ))
{
$id=$row["ID"];
$name=$row["name"];
$options.="<OPTION VALUE=\"$id\">".$name.'</option>';
}
sqlite_close($db);
?>
<SELECT NAME=id>
<OPTION VALUE=0>Choose
<?php echo $options ?>
</SELECT>
</body>
</html>
So now I need to have some code that would have textboxes that will allow to insert information about new picture for a given artist and store this information in the database. Any ideas? |
Hey GarryBrown
This is very easy to do. simple create text boxes and name them and then create same named field in your database of artist table. after all write db access code which is insert query for that....
Regards
Web Designing Lucknow
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|