Jump to content

how does phpmyadmin put data into the database


SnakZ

Recommended Posts

ok im sure we all know how phpmyadmin works. You click insert it grabs the column names/fields using mysql_fetch_field with the help of a loop im sure

then when you click submit it some how put them into the database

 

can any one tell me how does it do this ? what code is needed as im trying to do the same thing try to look at there code but its crazy in there :D

im not sure how it grabs the data and put it into the database

 

 

ty you for your time sorry if this is hard to understand its hard to put it into words :D

Link to comment
Share on other sites

got it to some what work with this code but now not to sure what type of loop i need to get the column name to change along with the array i know i need some type of loop using mysql_fetch_field

 

$tbox=$_POST['name'];
foreach ($tbox as $value)
  {
  echo" $key $value <br />";

sql_query("INSERT INTO table_Z ($column)VALUES ($value)")  or die(mysql_error());
  }

Link to comment
Share on other sites

[sOLVED]

 

ok i got it to work 100% just posting for that what if other people want to know how to :D

take an array from input and break it apart and put it into the database one by one

the "echo" are for me so i can see there names before they go into the SQL


$tbox=$_POST['name'];
$result = $db->sql_query("SELECT * FROM Table_Z ") or die(mysql_error()) ;
foreach ($tbox as $key => $value)
  {
  echo" $key $value <br />";

$property = mysql_fetch_field($result);

if($key==0){
        if  (ctype_digit($value)) {
        sql_query("INSERT INTO table_Z (" . $property->name . ")VALUES ('$value')")  or die(mysql_error());}else{
        sql_query("INSERT INTO table_Z (" . $property->name . ")VALUES ($value)")  or die(mysql_error());}
$test=$value;
echo"$test";
}else{
       if  (ctype_digit($value)) {
       $db->sql_query("UPDATE table_Z SET " . $property->name . "=$value WHERE names=$test")  or die(mysql_error());}else{
       $db->sql_query("UPDATE table_Z SET " . $property->name . "='$value' WHERE names=$test")  or die(mysql_error());}
}
}

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.