MySQL Select PHP
Here's a piece of code that works fine
/* Inject basic information, a_i automatically generate meta_id */$query 1 = "INSERT into Libr_metacode (META_ISBN, Meta_cip) VALUES (' $isbn ', ' $cip ')"; $result 1 = Mysqli_query ($DBC, $query 1) or Die (' cannot write basic encoding, error message: '. Mysqli_error ($DBC));/* Get meta_id for subsequent writes */$query = "SELECT * FR OM libr_metacode WHERE meta_isbn= ' $isbn ' "; $result = Mysqli_query ($dbc, $query); $row = Mysqli_fetch_array ($result); $ida = $row [' meta_id '];echo ' get the book Library system meta-code '. $ida. '
'; /* Title */$query 2 = "INSERT into Libr_title (meta_id, title, subtitle, series) VALUES (' $ida ', ' $title ', ' $subtitle ', ' $seri Es ') "; $result 2 = Mysqli_query ($dbc, $query 2) or Die (' cannot write the title information, Error: '. Mysqli_error ($DBC));
The thing to do is:
1. The ISBN Number (ISBN), the CIP number, which is obtained by the form, insert the line System Meta Code ISBN number in the Meta_code table
2. Use the unique ISBN number to query the system meta-codes obtained in the Meta_code table
3. Inserting in multiple tables with system meta-coding
Because ISBN has 13 bits not suitable for the master key (right?) ), so I did it, but the query code, which was almost identical when reading other data, went wrong.
/* Get meta_id for subsequent writes */$query = "select * from ' $ui _b ' WHERE ' $ui _c ' = ' $ui _a '"; $result = Mysqli_query ($dbc, $query); $row = My Sqli_fetch_array ($result); $ida = $row [' meta_id '];
Error: Mysqli_fetch_array () expects parameter 1 to be Mysqli_result, boolean given.
Although know $result should return is a resource ID but in the first paragraph of code Fetch_array () clearly can ah, why the second code in the Fetch_array () must be logical value?
Also, ask how can "echo" out the value of $result?
Reply to discussion (solution)
Add: The system meta-code is automatically incremented a_i, $ui _a input is the field value, $ui _b input is the table name, $ui _c input is the column name.
If $ui _b is a table name, $ui _c is the field name
You should write
$query = "SELECT * from $ui _b WHERE $ui _c= ' $ui _a '";
If $ui _b is a table name, $ui _c is the field name
You should write
$query = "SELECT * from $ui _b WHERE $ui _c= ' $ui _a '";
I'll go...... Yes, it is. Thank you Moderator!