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

2004-02-27 Thread Daniel Clark
Try:
" .$row["class_code"]. "";



> while ($row = mysql_fetch_array($sql))
> {
>  print "" .$row["class_code"]. "";
>  }
> $result = $db->query($sql);


>

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



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

2004-02-27 Thread Pavel Lobovich
> 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):
> -
> 
> Class Code:
> 
> 
>  $sql = mysql_query("SELECT DISTINCT class_code FROM class");
> while ($row = mysql_fetch_array($sql))
> {
>  print "" .$row["class_code"]. "";
>  }
> $result = $db->query($sql);
> 
> ?>
> 
> 

1. The variable $class_code is undefined. Use:

print ""
.$row["class_code"]. "";

2. Use mysql_fetch_assoc() instead mysql_fetch_array() if you want to
fetch hashed array ONLY.

3. After the form submitted the variable $_REQUEST[ 'class_code' ]
contains selected item value, for example "1234". You can insert it into
database using the following SQL query:

$sql = 'INSERT INTO `class` (`class_code`, `another_field`, `third_etc`
) VALUES( ' . mysql_escape_string( $_REQUEST[ 'class_code' ] ) . ',
"value", "value_etc" )';


Sorry for my english.

Pavel.

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



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

2004-02-27 Thread Mikael Grön
Irin,

First of all, you need to do this instead of what you're doing:
while ($row = mysql_fetch_row($sql))
Second, this value should be storable just as any other values.
i.e.
mysql_query("insert into database (table) values('" .  
$_POST['class_code'] . "')");

I hope this helps you a bit.
Regards, Mikael
On Feb 27, 2004, at 15:26, [EMAIL PROTECTED] wrote:

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):
--- 
--

Class Code:



$sql = mysql_query("SELECT DISTINCT class_code FROM class");
while ($row = mysql_fetch_array($sql))
{
 print "" .$row["class_code"].  
"";
 }
$result = $db->query($sql);

?>



--- 
--

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 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):
-

Class Code:


" .$row["class_code"]. "";
 }
$result = $db->query($sql);

?>



-

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