Jump to content

HELP w/ ARRAYS


lastgame2007

Recommended Posts

Hi i'am try to insert multiple data on a single submit, but i'm a total noob to Arrays, can any one help me out here... one of the members send me this out, but still i can figure it out how to insert the fields onto my database. it inserts but doesnt get the valuee.. Please help!

 

if(isset($_POST['save']))

{

unset($_POST['save']);

$i = count($_POST['id']); $x = 0;

for($x=0; $x <$i;$x++){

foreach($_POST as $data =>$d){

echo $data.'-'.$d[$x].'<br/>';

$insert = mysql_query("insert into tbl_grades");

//sql statement here (example): insert into table name (value of $data) values( value of$d[$x]) --

 

can anyone help me with this , how can i query to get the value of  this,

//HOW DO I MAKE MY SQL QUERY TO SAVE THIS OUT, I KNOW THIS IS MY PROBLEM IN THE QUERY....

 

here's my HTML

 

<input name="id[]" type="hidden" value="<?php echo $row['id'];?>" />

1st<input name="fg[]" type="text" id="fg[]" size="1" value="<?php  $g_sub['sub_id'];?>"/>

2nd<input name="sg[]" type="text" id="sg[]" size="1" value="<?php  $g_sub['sub_id'];?>"/>

3rd<input name="tg[]" type="text" id="tg[]" size="1" value="<?php  $g_sub['sub_id'];?>"/>

4th <input name="forg[]" type="text" id="forg[]" size="1" value="<?php  $g_sub['sub_id'];?>"/> ---- sub_id stands for subject id

Link to comment
Share on other sites

Please post the output of the query SHOW CREATE TABLE tbl_grades; You can run this in any MySQL client (such as the mysql CLI tool, phpMyAdmin, Workbench, etc).

 

Also, I'm a little confused with your HTML markup. You have 5 checkboxes with different names yet you are using the array syntax in the name.

 

What exactly are you trying to do?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.