You are here: saving multiple data... « PHP SQL « IT news, forums, messages
saving multiple data...

Posted by Zoran on 12/20/05 20:21

This is my problem:

In my form I have this five option menus (they are all taking values from
the same table) and one text field for each option menu (it should be
working something like datasheet in MS ACCESS):



<form name=" checkForm" method="POST">

<?php



$query = 'SELECT name FROM spare_part';

$result = mysql_query($query) or die ('Greska u upitu!');

if(mysql_num_rows($result) > 0)

{

echo '<tr valign="top" height="20">';

echo '<td height="28" align="right"> <b>
spare_part: </b> </td>';

echo '<td height="28" align="left"
nowrap="nowrap"><p><select name="thisSpare_partField">';



while($row = mysql_fetch_object($result))

{



echo '<option value="' . $row->spare_part_id. '">' .
$row->name . '</option>';



}

}

else

{

echo 'Nisu pronadeni podaci o rezervnim djelovima!';

}



?>

<td width="63" align="center"> <b> Quantity:</b> </td>

<td width="50"> <input type="text" name="thisQuantityField1" size="10"
value=""> </td>



<?php



$query = 'SELECT name FROM spare_part ';

$result = mysql_query($query) or die ('Greska u upitu!');

if(mysql_num_rows($result) > 0)

{

echo '<tr valign="top" height="20">';

echo '<td height="28" align="right"></td>';

echo '<td height="28" align="left"
nowrap="nowrap"><p><select name="thisSpare_partField">';



while($row = mysql_fetch_object($result))

{



echo '<option value="' . $row->spare_part_id. '">' .
$row->name . '</option>';



}

}

else

{

echo 'Nisu pronadeni podaci o rezervnim djelovima!';

}

?>

<td width="63" align="center"></td>

<td width="50"> <input type="text" name="thisQuantityField2" size="10"
value=""> </td>



<?php

$query = 'SELECT name FROM spare_part ';

$result = mysql_query($query) or die ('Greska u upitu!');

if(mysql_num_rows($result) > 0)

{

echo '<tr valign="top" height="20">';

echo '<td height="28" align="right"></td>';

echo '<td height="28" align="left"
nowrap="nowrap"><p><select name="thisSpare_partField">';



while($row = mysql_fetch_object($result))

{



echo '<option value="' . $row->spare_part_id. '">' .
$row->name . '</option>';



}

}

else

{

echo 'Nisu pronadeni podaci o rezervnim djelovima!';

}

?>

<td width="63" align="center"></td>

<td width="50"> <input type="text" name="thisQuantityField3" size="10"
value=""> </td>



<?php



$query = 'SELECT name FROM spare_part';

$result = mysql_query($query) or die ('Greska u upitu!');

if(mysql_num_rows($result) > 0)

{

echo '<tr valign="top" height="20">';

echo '<td height="28" align="right"></td>';

echo '<td height="28" align="left"
nowrap="nowrap"><p><select name="thisSpare_partField">';



while($row = mysql_fetch_object($result))

{



echo '<option value="' . $row->spare_part_id. '">' .
$row->name . '</option>';



}

}

else

{

echo 'Nisu pronadeni podaci o rezervnim djelovima!';

}

?>

<td width="63" align="center"></td>

<td width="50"> <input type="text" name="thisQuantityField4" size="10"
value=""> </td>



<?php



$query = 'SELECT name FROM spare_part';

$result = mysql_query($query) or die ('Greska u upitu!');

if(mysql_num_rows($result) > 0)

{

echo '<tr valign="top" height="20">';

echo '<td height="28" align="right"></td>';

echo '<td height="28" align="left"
nowrap="nowrap"><p><select name="thisSpare_partField">';



while($row = mysql_fetch_object($result))

{



echo '<option value="' . $row->spare_part_id. '">' .
$row->name . '</option>';



}

}

else

{

echo 'Nisu pronadeni podaci o rezervnim djelovima!';

}

?>

<td width="63" align="center"></td>

<td width="50"> <input type="text" name="thisQuantityField5" size="10"
value=""> </td>



</table>





<p>

<input type="submit" name="submitCheckForm" value="Submit">

</p>

</form>



MySql tables look like this:



Baza: `servis`

CREATE TABLE `check` (

`check_id` int(10) unsigned NOT NULL auto_increment,

`fname` varchar(35) NOT NULL default '',

`lname` varchar(35) NOT NULL default '',

`adress` varchar(60) NOT NULL default '',

`garancy` binary(1) NOT NULL default '0',

`check_number` int(11) NOT NULL default '0',

`date_number` date NOT NULL default '0000-00-00'

PRIMARY KEY (`check_id`)

) ENGINE=InnoDB;



CREATE TABLE `check_spare` (

`check_id` int(10) NOT NULL default '0',

`spare_part_id` int(11) NOT NULL default '0',

`quantity` int(100) NOT NULL default '0'

PRIMARY KEY ('check_id`)

PRIMARY KEY (`spare_part_id `)

) ENGINE=InnoDB;



CREATE TABLE `spare_part` (

`spare_part_id` int(10) NOT NULL auto_increment,

`name` varchar(100) NOT NULL default '',

`price` int(11) NOT NULL default '0',

`description` varchar(255) default NULL,

PRIMARY KEY (`spare_part_id`)

) ENGINE=InnoDB;





What I don't know is how and where do I insert this selected values to be
able to show them latter with some kind of select query. I was working with
ms access and in it this table 'check_spare' should be looking something
like this:



Check_id spare_part_id quantity

3 part 1 2

3 part 2 1

3 part 3 4

3 part 4 1

3 part 5 2



If someone can help me or know where can I find some similar example I would
be thankful!



Zoran

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация