Re: [PHP-DB] INSERT problem--Need help urgently

2004-03-30 Thread irinchiang
sorie it was my typo error. actually in my code there is already {} with my 
first if statement and there is also a space after VALUES...
I still need some help here with my code...how can I prevent it from inserting 
a duplicate row of null values???

Anyone can help ?

Thanks in advance.

Regards, 
Irin
---
Hi, 

I'm not very good at reading other people code, but : 
there is no { } with your first if statement 
there is no space after VALUES 

Sorry I don't have time to test what I'm writing. 
hope it helps 
Chris 

Hi all: 
 
I was having some problem with INSERT query here and do hope to get some help 
real soon. 
 
I have a form whereby once the form is submitted, the values entered shall be 
inserted into the database. Next I have also written a SELECT query 
to view the 
records which have just been inserted into the database. 
 
Data was able to insert into the database and I was also able to 
retrieve these 
data from database. However, my problem is, whenever a form was being 
submitted, it actually INSERT another row of null values into the 
database. And 
so, when I clicked to view my data, i can see the previously 
inserted values as 
well as an empty row of records. 
 
Why is this so? How can I prevent the row of null value to be inserted? 
 
I have included a snip of my code below and hope to get some help real soon. 
All help are greatly appreciated. Thanks in advance. 
 
snip 
 
$dsn = mysql://root:[EMAIL PROTECTED]/databaseName; 
 
$db = DB::connect ($dsn); 
if (DB::isError ($db)) 
die ($db-getMessage()); 
 
$tutor_name = $_POST[tutor_name]; 
$tutor_contact = $_POST[tutor_contact]; 
$tutor_email = $_POST[tutor_email]; 
$tutor_profile = $_POST[tutor_profile]; 
 
$sql =INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, 
tutor_profile) 
 
VALUES('$tutor_name','$tutor_contact','$tutor_email','$tutor_profile'); 
 
 
$result = $db-query($sql); 
 
if( DB::isError($result) ) { 
 die ($result-getMessage()); 
} 
 
? 
 
/snip 
 
Is there anything wrong with my SELECT query ?? 
 
Thanks in advance. 
 
Regards, 
Irin 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] INSERT problem--Need help urgently

2004-03-29 Thread irinchiang
Hi all:

I was having some problem with INSERT query here and do hope to get some help 
real soon.

I have a form whereby once the form is submitted, the values entered shall be 
inserted into the database. Next I have also written a SELECT query to view the 
records which have just been inserted into the database. 

Data was able to insert into the database and I was also able to retrieve these 
data from database. However, my problem is, whenever a form was being 
submitted, it actually INSERT another row of null values into the database. And 
so, when I clicked to view my data, i can see the previously inserted values as 
well as an empty row of records. 

Why is this so? How can I prevent the row of null value to be inserted?

I have included a snip of my code below and hope to get some help real soon. 
All help are greatly appreciated. Thanks in advance.

snip

$dsn = mysql://root:[EMAIL PROTECTED]/databaseName;

$db = DB::connect ($dsn);
   if (DB::isError ($db))
   die ($db-getMessage());

$tutor_name = $_POST[tutor_name];
$tutor_contact = $_POST[tutor_contact];
$tutor_email = $_POST[tutor_email];
$tutor_profile = $_POST[tutor_profile];

$sql =INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile)
   VALUES('$tutor_name','$tutor_contact','$tutor_email','$tutor_profile');


$result = $db-query($sql);

if( DB::isError($result) ) {
die ($result-getMessage());
}

?

/snip

Is there anything wrong with my SELECT query ??

Thanks in advance.

Regards, 
Irin

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Select Query--Need help urgently

2004-03-26 Thread irinchiang
Hi all, 

I am having having a slight problem with SELECT query statement.

I have a table Class. The table are as follow:

++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| class_id   | int(11)  |  | PRI | NULL| auto_increment |
| class_code | varchar(255) |  | | ||
| edu_level  | varchar(16)  |  | | ||
| student_name   | varchar(255) |  | | ||
| tutor_name | varchar(255) |  | | ||
| timetable_day  | varchar(255) |  | | ||
| timetable_time | varchar(255) |  | | ||
++--+--+-+-++

I am doing a SELECT query to retrieve some of the fields like timetable_time, 
tutor_name, class_code and edu_level from the table WHERE the timetable_day is 
equal to Monday . Meaning it will display fields only when the timetable_day 
value is Monday

Below is a snip of my code:

snip

$timetable_time = $_GET[timetable_time];
$class_code = $_GET[class_code];
$edu_level = $_GET[edu_level];
$tutor_name = $_GET[tutor_name];

$sql = mysql_query(SELECT * FROM class where timetable_day='Monday');

$row = mysql_fetch_array($sql);
$result = $db-query($sql);
$numofrows = mysql_num_rows($sql);

echo div align=\center\;
echo div id=\pagecontent5\;
echo table border=\0\ width=\700\ \n;
echo tr class=\darker\;
echo td align=\center\ colspan=\4\bMonday/b/td/tr;
echo trtd align=\center\ class=\darkgreen\ width=\200\Time/td;
echo td align=\center\ class=\lightgreen\ width=\150\Classcode/td;
echo td align=\center\ class=\darkgreen\ width=\150\Level/td;
echo td align=\center\ class=\lightgreen\ width=\200\Tutor/td/tr;
echo /div;


echo trtd align=\center\ class=\darker\ width=\200\.$row
['timetable_time']./td;
echo td align=\center\ class=\lighter\ width=\150\.$row
['class_code']./td;
echo td align=\center\ class=\darker\ width=\150\.$row
['edu_level']./td;
echo td align=\center\ class=\lighter\ width=\200\.$row
['tutor_name']./td/tr;
echo /div;

/snip

But I was unable to retrieve the values from database. Was it because I have 
written the SELECT query wrongly??

Realli need some help urgently..Hope to hear from all soon. Thanks in advance.

Regards, 
Irin

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] INSERT dynamic values problem - Need help urgently!

2004-02-27 Thread irinchiang
Hi all:

I am trying to create a registration form whereby one of the user input is as 
follows: (a drop down menu with values retrieved from DB):
-

td class=lighter width=350Class Code:/td
td class=lighter width=450
select class=textarea name=class_code
?
$sql = mysql_query(SELECT DISTINCT class_code FROM class);
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$class_code\  .$row[class_code]. /option;
 }
$result = $db-query($sql);

?

/select

-

My problem was:

1. I was unable to print the values I have selected from this drop down menu 
and 

2. insert this dynamic values into the DB??

I was able to insert static values into DB but not dynamic values...
How should I go about doing this? 
Really need some help here...


Thanks in advance. All help are greatly appreciated.


Regards,
 
Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] INSERT into mysql from dynamic drop down

2004-01-06 Thread irinchiang

Hi all, 

   Right now i would like to INSERT the values from a dynamic drop down 
menu into mysql database but encountered some problem here. Values in the drop 
down menu are retrieved from DB as follows:

SNIP

SELECT NAME=tutor_name CLASS=textarea
?


$sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor);
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\  .$row[tutor_name]. /option;
 }
$result = $db-query($sql);

?
/SELECT

/SNIP

---

echo $_POST[tutor_name];

INSERT statement:

$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day, 
timetable_time)
VALUES 
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time');

---

I am trying to POST the values and then INSERT into DB but was not able to do 
so(all other values eg. class_code, edu_level etc...was able to be 
INSERTED into DB but not tutor_name. So, how do i insert values into DB from 
a dynamic drop down and where have i gone wrong???Hope to get some help real 
soon.=)

All help are greatly appreciated. Thanks in advance.


Regards, 
Irin. 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Problem with INSERT Query

2003-12-30 Thread irinchiang


Hi all:

Well, when i bring out the page with the drop down list it was able to display 
all tutors' names from tutor_name column. Anyway here's a review of my code
(snip) again before i continue:
---
snip 
$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,   
timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time');


?//retrieve data from DB  display in dynamic drop down ? 

SELECT class=textarea name=tutor_name / 
?


$sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor );
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\ SELECTED  .$row
[tutor_name]. /option ;
 }
 $result = $db- query($sql);

? 
/select 

?

while($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];

? 

/snip 

---

so when i submit the form, i am suppose to echo the values i have entered into 
the field and then INSERT the values into DB (Queries stated above). However i 
was able to echo all other values eg. class_code, edu_level, etc...but 
not tutor_namesame thing happen when i do an INSERT, all other values 
are inserted into DB but not $tutor_namewhy is this so???Really need some 
help here...Anyway i have already specify a name to be reference :

SELECT class=textarea name=tutor_name  

and then I also did an echo of tutor_name being selected:

while($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];

All help are greatly appreciated =)

Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Re: Display Mysql Result in drop down list

2003-12-25 Thread irinchiang
Hi:

Well, when i bring out the page with the drop down list it was able to display 
all tutors' names from tutor_name column. Anyway here's a review of my code
(snip) again before i continue:
---
snip
$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,   
timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time');


?//retrieve data from DB  display in dynamic drop down ?

SELECT class=textarea name=tutor_name /
?


$sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor );
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\ SELECTED .$row
[tutor_name]. /option;
 }
 $result = $db-query($sql);

?
/select

?

while($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];

?

/snip

---

so when i submit the form, i am suppose to echo the values i have entered into 
the field and then INSERT the values into DB (Queries stated above). However i 
was able to echo all other values eg. class_code, edu_level, etc...but 
not tutor_namesame thing happen when i do an INSERT, all other values 
are inserted into DB but not $tutor_namewhy is this so???Really need some 
help here...Anyway i have already specify a name to be reference :

SELECT class=textarea name=tutor_name 

and then I also did an echo of tutor_name being selected:

while($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];

All help are greatly appreciated =)

Irin.

---
On Tue, 23 Dec 2003 16:00:04 -0500, Aleks @ USA.net [EMAIL PROTECTED] wrote:
---
Hi, 

I am looking at your code and have a question, in your code you have 

print OPTION VALUE=\$tutor_name\ SELECTED .$row [tutor_name]. 
/option; 

Doesn't the SELECTED piece mark everything listed as selected?? When you 
bring up the page with the drop down list and open the source, what does it 
show?? 

I handle this  a little differently, I create my drop down list as follows: 

=== Code used  

// First I retrieve all customer information 

$BB = mysql_query(SELECT * FROM customer ORDER BY CID ); 



// Then I create the drop down list 

SELECT style=WIDTH: 410px size=1 name=Customer 


? 
 // Creates the Customer dropdown with the $id number 
   while ($Site = mysql_fetch_array($BB)) 
  { 
$Sid = $Site[CID]; 
$Sname = htmlspecialchars($Site[Customer]); 
$SCity = htmlspecialchars($Site[City]); 
$SState = htmlspecialchars($Site[State]); 
$SCountry = htmlspecialchars($Site[Country]); 


if($Sid == $Customer) 
{ $add = ' selected'; } else { $add = ''; } 
  
echo(option value='$Sid'$add$Sname nbsp;nbsp;nbsp; $SCity 
nbsp;nbsp;nbsp; $SState nbsp;nbsp;nbsp; $SCountry /option\n);   

  } 
  
? 

/select 

=== Code used  

This will create a drop down list where the value of the option is the sites 
ID. In another part of this form, if there is a value set for $Customer, 
then it will set the $add to selected. This will then make the drop down 
list auto select the customer. 

The code above is passed to another form for processing and is were the 
insert data occurs. Using this method I can echo the form data easily 

Hope this helps... 

Aleks 



-Original Message- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 23, 2003 4:33 AM 
To: David Robley 
Cc: [EMAIL PROTECTED] 
Subject: Re: [PHP-DB] Re: Display Mysql Result in drop down list 

Hi: 

then now i'm trying to select a value from the drop down list, echo the 
value i have selected and lastly INSERT the value into DB with the following 
: 
Below's a snippet of code: 

snip 
//retrieve all tutor_name from DB and display in drop down list 

SELECT class=textarea name=tutor_name / ? 


$sql = mysql_query(SELECT tutor_name FROM tutor ); while ($row = 
mysql_fetch_array($sql)) {  print OPTION VALUE=\$tutor_name\ SELECTED 
.$row [tutor_name]. /option;  }  $result = $db-query($sql); 

? 
/select 

/snip 

snip 
***INSERT selected values into 
DB** $tutor_name = $_POST[tutor_name]; 

$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day, 
timetable_time) 
VALUES 
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time' 
); 

//execute query statement 
$result = $db-query($sql); 

/snip 


snip 
*echo the value i have 
selected*** 
? 
if($selected_tutor_name == $tutor_name) 
echo $_POST[tutor_name]; 
? 

/snip 


Problem: I was unable to echo the value i selected from drop down as well as 
INSERT into 

Re: [PHP-DB] Re: Display Mysql Result in drop down list

2003-12-23 Thread irinchiang
Hi:

then now i'm trying to select a value from the drop down list, echo the value 
i have selected and lastly INSERT the value into DB with the following :
Below's a snippet of code:

snip
//retrieve all tutor_name from DB and display in drop down list

SELECT class=textarea name=tutor_name /
?


$sql = mysql_query(SELECT tutor_name FROM tutor );
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\ SELECTED .$row
[tutor_name]. /option;
 }
 $result = $db-query($sql);

?
/select

/snip

snip
***INSERT selected values into DB**
$tutor_name = $_POST[tutor_name];

$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day, 
timetable_time)
VALUES 
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time');

//execute query statement
$result = $db-query($sql);

/snip


snip
*echo the value i have selected***
?
if($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];
?

/snip


Problem: I was unable to echo the value i selected from drop down as well as 
INSERT into DB...wonder where have i gone wrong???
Reali need some help here...all help are greatly appreciated =)
Thanks in advance.


Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] INSERT into 2 different tables??

2003-12-23 Thread irinchiang


Hi all:

Just wana ask is it possible to have only one form and when i submit, it 
should INSERT data into 2 diff tables??
Hope u get my idea...


Merry X'Mas!!

Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Display Mysql Result in drop down list

2003-12-22 Thread irinchiang

Hi all, 

Right now I'm trying to retrieve one of the column tutor_name and display al 
the tutor's name in a drop down list. The problem now is, the drop down list 
only manage to display 1 record from that row instead of all tutor's name 
under tutor_name column...wonder where the problem lies??
Hope to get some help soon.
Below is a snip of the code: 
Drop me a msg if anyone needs the entire code.



SELECT NAME=tutor_name class=textarea
?


$sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor );
if ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\ SELECTED .$row
[tutor_name]. /option;
 }
 $result = $db-query($sql);

?
/select


Thanks in advance =)

Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Need help!!!

2003-12-12 Thread irinchiang


Hi..

Anyone can help me with this script???I kept getting error saying i did not 
define the variable $tutor_id and whenever I define it as $tutor_id = $_POST
['tutor_id'], I got error saying there was an Undefined index!
What was exactly the problem??
Need help desperately , greatly appreciate any suggestions/help/solutions 
given...

---

===edit.php 
 
$dsn = mysql://root:[EMAIL PROTECTED]/tb1; 
$db = DB::connect ($dsn); 

   if (DB::isError ($db)) 
   die ($db-getMessage()); 

$action = $_GET[action]; 

if($action == delete) 
{ 
$sql = mysql_query (DELETE FROM tutor WHERE tutor_id='$tutor_id'); 
} 

if($action == edit) 
{ 
$sql = mysql_query (SELECT * FROM tutor WHERE tutor_id 
='$tutor_id');**ERROR HERE!!* 

$row = mysql_fetch_array($sql); 

echo form name=\edit_tutor\ method=\post\ action=\edit2.php\; 
echo Tutor ID : .$row['tutor_id'].br; 
echo input type=\hidden\ name=\tutor_id\ value=\.$row 
['tutor_id'].\; 
echo Name : input name=\tutor_name\ type=\text\ value=\.$row 
['tutor_name'].\br; 
echo Contact No : input type=\text\ name=\tutor_contact\ value=\.$row 
['tutor_contact'].\br; 
echo E-mail : input type=\text\ name=\tutor_email\ value=\.$row 
['tutor_email'].\br; 
echo Profile : input type=\text\ name=\tutor_profile\ value=\.$row 
['tutor_profile'].\br; 
echo input type=\submit\ name=\Submit\ value=\Update\; 
echo /form; 

} 
? 

$result = $db-query($sql); 

if( DB::isError($result) ) { 
die ($result-getMessage()); 
} 
---


Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Need help!!!

2003-12-12 Thread irinchiang


Yes I'm using a hyperlink to access this page (see below)
echo tda href=\edit.php?id=.$row
[tutor_id].action=edit\Modify/a/td;

and so I defined my variable $tutor_id as $tutor_id = $_GET['tutor_id'];
but i still got the error: Undefined index: tutor_id 
in /usr/local/apache/htdocs/tutor/edit.php 

WHat could be the problem?;(


---

how are you getting the $tutor_id var?, in your script you are using $action 
= $_GET[action]; so you will need to define $tutor_id like $tutor_id = $_GET
['tutor_id'], or just use $_GET['tutor_id']. 

a form can only put variables in the POST array OR the GET array, and if your 
using hyperlinks to access this script then they will of course be GET vars. 

-Original Message- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 12 December 2003 09:38 
To: [EMAIL PROTECTED] 
Subject: [PHP-DB] Need help!!! 




Hi.. 

Anyone can help me with this script???I kept getting error saying i did not 
define the variable $tutor_id and whenever I define it as $tutor_id = $_POST 
['tutor_id'], I got error saying there was an Undefined index! 
What was exactly the problem?? 
Need help desperately , greatly appreciate any suggestions/help/solutions 
given... 

---
 

===edit.php 
 
$dsn = mysql://root:[EMAIL PROTECTED]/tb1; 
$db = DB::connect ($dsn); 

   if (DB::isError ($db)) 
   die ($db-getMessage()); 

$action = $_GET[action]; 

if($action == delete) 
{ 
$sql = mysql_query (DELETE FROM tutor WHERE tutor_id='$tutor_id'); 
} 

if($action == edit) 
{ 
$sql = mysql_query (SELECT * FROM tutor WHERE tutor_id 
='$tutor_id');**ERROR HERE!!* 

$row = mysql_fetch_array($sql); 

echo form name=\edit_tutor\ method=\post\ action=\edit2.php\; 
echo Tutor ID : .$row['tutor_id'].br; 
echo input type=\hidden\ name=\tutor_id\ value=\.$row 
['tutor_id'].\; 
echo Name : input name=\tutor_name\ type=\text\ value=\.$row 
['tutor_name'].\br; 
echo Contact No : input type=\text\ name=\tutor_contact\ value=\.$row 
['tutor_contact'].\br; 
echo E-mail : input type=\text\ name=\tutor_email\ value=\.$row 
['tutor_email'].\br; 
echo Profile : input type=\text\ name=\tutor_profile\ value=\.$row 
['tutor_profile'].\br; 
echo input type=\submit\ name=\Submit\ value=\Update\; 
echo /form; 

} 
? 

$result = $db-query($sql); 

if( DB::isError($result) ) { 
die ($result-getMessage()); 
} 
---
 


Irin. 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Thanks alot Griffiths!=)

2003-12-12 Thread irinchiang


Thanks alot for your help! That was very careless of me..;p I was stil quite a 
newbie to php-db coding...

By the way one last favour to ask of u hope u dun mind...

I have a script which was used to INSERT data into the database:
(See script below):

But everytime when I execute it I got the error DB constraint

I think the problem lies here:

$sql = INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, 
tutor_profile)
VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile);

Whenever I single quote the string value:
 VALUES ($tutor_name','$tutor_contact','$tutor_email','$tutor_profile');
it actually insert a NULL value into the DB though I did enter values into the 
text field.But if I dun quote it, I got the error:
DB constraint. By right I ought to quote it right??
I have gone thru my code umpteen times but to no avail. 
Where have i gone wrong??? ;(

---

$dsn = mysql://root:[EMAIL PROTECTED]/table1;

$db = DB::connect ($dsn);
   if (DB::isError ($db))
   die ($db-getMessage());

//create variables ready to go into DB

$tutor_name = $db-quote($_POST[tutor_name]);
$tutor_contact = $db-quote($_POST[tutor_contact]);
$tutor_email = $db-quote($_POST[tutor_email]);
$tutor_profile = $db-quote($_POST[tutor_profile]);

$sql = INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, 
tutor_profile)
VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile);

$result = $db-query($sql);
  if( DB::isError($result) ) {
die ($result-getMessage());
}
?HTML
head
titleAdd Tutor/title

!-- **CSS and HTML** --

/head
body
div align=center
div id=pagecontent5
?php if( $_POST[submit] != Save )
{
?

div align=center
form name=classinfo action=?php echo $_SERVER[PHP_SELF]; ?  
method=post
input type=hidden name=form_submitted value=1

table name=add_tutor  border=0px cellpadding=0 cellspacing=2 
width=900tr
 td class=lighter width=200Name:/td
 td class=lighter width=500Input type=text size=50 
name=tutor_name/td
   /tr
tr
td class=darker width=150Contact No:/td
td class=darker width=150Input type=text size=30 
name=tutor_contact/td
   /tr
tr
td class=lighter width=150Email:/td
 td class=lighter width=150Input type=text size=50 
name=tutor_email/td
   /tr

tr
td class=darker width=150Profile:/td
 td class=darker width=150TEXTAREA class=textarea 
NAME=tutor_profile ROWS=6 COLS=70
/TEXTAREA
/td
/tr
tr
td class=lighter width=150/td
 td class=lighter width=150a href=teacher_summary.php
div align=centerinput type=submit name=submit  
value=Save/div/a/td
   /tr
/table
/form
br


?php } else {?
table border=0
tr
td class=darker width=300Teacher:/td
td class=darker width=600
?
echo $_POST[tutor_name];
?
/td
/tr
trtd class=lighter width=300Contact No:/td
td class=lighter width=600
?
echo $_POST[tutor_contact];
?
/td
/tr
tr
td class=darker width=300E-mail Address:/td
td class=darker width=600
?
echo $_POST[tutor_email];
?
/td
/tr
tr
td class=lighter width=300Profile:/td
td class=lighter width=600
?
echo $_POST[tutor_profile];
?
/td
/tr
/body
/html
/div
/div
?}?

---
(I'm terribly sorry if the code is kinda messy)

All help are greatly appreciated!

Irin.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Need HELP with UPDATE DELETE

2003-12-11 Thread irinchiang

Hi all, 

Right now I'm trying to do a UPDATE and DELETE queries using the following 
code below: But i kept getting error 
Undefined variable: tutor_id in /usr/local/apache/htdocs/tutor/edit.php on 
line .
Didn't I defined my variable $tutor_idI thought I have...
Anyone can help???
Thanks in advance =)

Below is a snip of my code :

---
===edit.php

$dsn = mysql://root:[EMAIL PROTECTED]/tb1;
$db = DB::connect ($dsn);

   if (DB::isError ($db))
   die ($db-getMessage());

$action = $_GET[action];

if($action == delete)
{
$sql = mysql_query (DELETE FROM tutor WHERE tutor_id='$tutor_id');
}

if($action == edit)
{
$sql = mysql_query (SELECT * FROM tutor WHERE tutor_id 
='$tutor_id');**ERROR HERE!!*

$row = mysql_fetch_array($sql);

echo form name=\edit_tutor\ method=\post\ action=\edit2.php\;
echo Tutor ID : .$row['tutor_id'].br;
echo input type=\hidden\ name=\tutor_id\ value=\.$row
['tutor_id'].\;
echo Name : input name=\tutor_name\ type=\text\ value=\.$row
['tutor_name'].\br;
echo Contact No : input type=\text\ name=\tutor_contact\ value=\.$row
['tutor_contact'].\br;
echo E-mail : input type=\text\ name=\tutor_email\ value=\.$row
['tutor_email'].\br;
echo Profile : input type=\text\ name=\tutor_profile\ value=\.$row
['tutor_profile'].\br;
echo input type=\submit\ name=\Submit\ value=\Update\;
echo /form;

}
?

$result = $db-query($sql);

if( DB::isError($result) ) {
die ($result-getMessage());
}

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php