PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 19th, 2013, 03:58 PM
GarryBrown GarryBrown is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 7 GarryBrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.
Comments on this post
rtbd agrees!

Reply With Quote
  #2  
Old February 19th, 2013, 04:01 PM
GarryBrown GarryBrown is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 7 GarryBrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #3  
Old March 15th, 2013, 05:34 AM
nitinsankar nitinsankar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Location: L.D.A. Colony, Kanpur Road Lucknow, India 226012
Posts: 1 nitinsankar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 52 sec
Reputation Power: 0
Thumbs up

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

Reply With Quote
  #4  
Old May 23rd, 2013, 04:53 AM
BohdanNykon BohdanNykon is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2013
Posts: 12 BohdanNykon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 11 sec
Reputation Power: 0
yes you are right. This is much better way to create third column. thanks

Reply With Quote
  #5  
Old January 23rd, 2014, 12:04 AM
jj91171 jj91171 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2013
Posts: 2 jj91171 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 34 sec
Reputation Power: 0
php function heading

what is function in php and how to use function in advance level

______________________________________

Reply With Quote
  #6  
Old April 22nd, 2014, 12:15 AM
jaysh4922 jaysh4922 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2014
Posts: 2 jaysh4922 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 4 sec
Reputation Power: 0
One of the most powerful features of PHP is the way it handles HTML forms. The basic concept that is important to understand is that any form element will automatically be available to your PHP scripts.

like
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP forms


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap