473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to call a field name from database and link it with another database in php

Hello guys..I have multiple checkboxes in form. Now the value of checkbox has been successfully entered into the database. Here are my checkbox form:

Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="">
  2.        <div align="left">
  3.        <p align="left">
  4.  
  5.         <input type="checkbox"  name="BMK81A"     value="BMK81A"  > 1. BMK81A <br>
  6.  
  7.        <input type="checkbox" name="BMK81" value="BMK81" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  8.       2. BMK81 <br>
  9.  
  10.       <input type="checkbox" name="DL3" value="DL3" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  11.       3. JPN-DL-3 / JPN-DL-4  <br>       
  12.  
  13.       <input type="checkbox" name="DL2" value="DL2" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  14.       4. JPN-DL-2 <br>
  15.  
  16.       <input type="checkbox" name="DL1" value="DL1" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  17.       5. JPN-DL-1 <br>
  18.  
  19.     </div>
  20. </form>


Now code for insert into database:

Expand|Select|Wrap|Line Numbers
  1. $insert_data7=mysql_query(" INSERT into docu (BMK81A,BMK81,DL3,DL2,DL1) VALUES  ('$BMK81A','$BMK81','$DL3','$DL2','$DL1') ") or die(mysql_error());

At database when to store the value of checkbox it become like this: i can't insert the image to show

-| BMK81A | BMK81 | DL3 | DL2 | DL1

| | BMK81 | | DL2 |

As you guys can see graph.... if user make a selection of checkbox and the value has been insert into database. after that, what I want is to make it display the description of "DOCUMENT"..

Let me explain clearly.. I have second table in database named name_Document which is has field of CODE and DESC.. EXAMPLE:

CODE | DESC : DL2 | JPN-DL-2 DL3 | JPN-DL-3/JPN-DL-4 and so on...

So now if user make a selection at form. i want it can be display..when data has insert into database..it will refer to second table to call for a description...can anyone help me?:'( please help me..:'(


For better understanding:
What I want is from table one value of checkbox has inserted. Then part of displayed, ,it will refer from table two for code and description if true..means.. if BMK81A succeeded insert into database, I just want the description of BMK81A will be appear. Only the value of checkbox that inserted will appear to be displayed. help me..
Oct 29 '14 #1
1 1289
Claus Mygind
571 512MB
You are dealing with two things here. both php and javascript.

If you want to return information back to the user's computer screen you will have to make an ajax call or stream out a new page (which is much more work).

Once you have done your insert you could do a read of the schema for table two and return the information you want.

Here is how you could read the schema. Pass the function the table name you want to look up $t1.
Expand|Select|Wrap|Line Numbers
  1.     function getFieldList($t1)
  2.     {
  3.         /*
  4.         --------------------------------------------------
  5.         query the table schema of this table to be updated
  6.         --------------------------------------------------
  7.         */
  8.         $query =  "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '".$t1."'";
  9.  
  10.         /*
  11.         ---------------------------------------
  12.         Store column information of this table
  13.         in an array
  14.         ---------------------------------------
  15.         */
  16.         $aFieldList = array();
  17.  
  18.         if ($result = $this->query($query)) 
  19.         {
  20.             /* fetch associative array */
  21.             while ($row = $result->fetch_assoc()) {
  22.                 $aFieldList[$row['COLUMN_NAME']] = 
  23.                 array(    
  24.                     "name"=>        $row['COLUMN_NAME'],     
  25.                     "type"=>        $row['DATA_TYPE'],     
  26.                     "length"=>        $row['CHARACTER_MAXIMUM_LENGTH'], 
  27.                     "numeric"=>        $row['NUMERIC_PRECISION'], 
  28.                     "decimal"=>        $row['NUMERIC_SCALE'],
  29.                     "isAutoInc"=>    $row['EXTRA'],
  30.                     "isKey"=>        $row['COLUMN_KEY'], 
  31.                     "default"=>        $row['COLUMN_DEFAULT']
  32.                     );
  33.  
  34.             }
  35.             /* free result set */
  36.             $result->free();
  37.         }
  38.  
  39.         /* close connection */
  40.         return $aFieldList;
  41.     }    
  42.  
But I suspect that your real question is more simple that that. Perhaps you are asking how can you use the value inserted into table one to look up a value in table 2 and return that value to be displayed for the user. In that case just do a second sql query on table 2 in the database.
Oct 30 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Consuelo Guenther | last post by:
Hello, I have an asp page that has a function that connects to an Access database. I am using Javascript. Is there any way to reference the field name in the database through a variable in a sql...
1
by: Lothar Armbr?ster | last post by:
Hello out there, this morning I had to get some rows via flashback query. Since my undo retention is just 3h, the undo segments were already aged out. But I have a physical standby database that...
2
by: FrankS | last post by:
Hi All, I have a problem with an call-template cmd at xslt 1.0: With: pCall = 'ExInput' ------ I try to: <xsl:call-template name="{$pCall}"> <xsl:with-param name="pVal" select="$pValue"/>...
11
by: Eych | last post by:
I get a VB error when I try to update a table whose field I change with the following statement: dcUpdate.Dataset.Tables(0).Rows(0)("User Name") = Me.textbox1.Text if I change the field name...
5
by: HS1 | last post by:
Hello I have a datagrid to show data for a database table using "seclect * from tablename" The datagrid works OK. However, I want to change the name of the fields in the database to other...
3
by: ineedahelp | last post by:
Hi, can anyone help me with the code necessary to rename a field in an access table. I have tried the ALTER TABLE method but it doesn't like my variable names. Here is the code and thank you for...
6
by: karen987 | last post by:
I have a webpage called "topicview.asp" on a news website with ASP pages, it's a simple news publishing software. You add the news from the Admin section and all the details are stored in a...
8
by: colemanj4 | last post by:
Hello, I have a field in a table that I need changed to due to some barcode scanning software that will be using the ODBC link to this database that does not like to work with '?' in the field...
1
by: bassi.carlo | last post by:
I have an application with many combobox in different forms used for choose a particular length (for example items are "ft" - feet, "in" - inch, "m" - meters, and so on). I don't want to put in...
3
by: jeanydoggy | last post by:
I need to use a variable value as a table field name. But when I ran the code, it gave me error and didn't use variable value but used the variable as the field name. I defined the following Sub and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.