What Tables Were Inserted Into The Mysql Database
tell me what tables were inserted into the mysql database for the car makes and models. i m stuck on what to have the table names as,and the field names.
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Inserted Data Into 2 Tables
I have wrote the following queries but the values being entered into the table are not right (see tables below). The project_ID isn't the same in both tables: PHP Code: if (isset($_POST['submit']) && $_POST['submit'] == "Create Project") { if ($_POST['lecturer_role'] != " " && $_POST['SK_ID'] != " " && $_POST['project_name'] != " " && $_POST['project_description'] != " ") { mysql_query("INSERT INTO student_project (project_ID, lecturer_role, LK_ID, SK_ID, project_name, project_desc) VALUES('$projectid', '" . $_POST['role'] . "', '" . $_SESSION['user_logged'] . "', '" . $_POST['students'] . "', '" . $_POST['project_name'] . "', '" . $_POST['project_desc'] . "') ") ; mysql_query("INSERT INTO project_assess ......................
View Replies !
View Related
Database Value Inserted
I have a simple form; PHP Code: <INPUT TYPE="HIDDEN" NAME="username" VALUE="Brin"> PHP Code: echo $result['id']; I get a number. I want to put this number after the "Brin" So. If number is 2 then Brin + "2" = Brin2 192 + "2" = 1922 I'd also like to be able to do this the other way around. "2" + 234 = 2234
View Replies !
View Related
Cannot Create Mysql Database And Tables From Php Script
'm trying to build a php script that will build a database in MySQL, create tables, and then populate those tables. 1. I'm not sure how I need to execute the php, from the browser or from the command line? 2. I'm not sure what is wrong with my code, but when I use php -v createdatabase.php, I get output that says my php function to create the database is incorrect. I've looked at other examples on google, and they seem to be almost the same...? Here is the code, I've gone thru it, but I still don't see where I'm making the error: Code:
View Replies !
View Related
Selecting From Multiple Tables In Mysql Database
I want to make an RSS feed displaying the latest updates on my website. My site has 3 sections: reviews, interviews and news. I want to combine them into 1 RSS feed. So that means I have to find the 10 newest items throughout all 3 database tables. The problem is that the tables have some fields in common (like 'activated_dt', a datetime field) but not all. What would be a good query to find the 10 newest items?? SELECT ID FROM reviews,interviews,news ORDER BY activated_dt DESC LIMIT 10 But how do I know what table the ID is from?
View Replies !
View Related
Altering Tables In The `mysql` Database - Safe?
I wanted to add some fields to the permissions tables in the mysql database, mainly an EditDate TIMESTAMP(14) field to know when the permission was added. Are there any special precautions when adding fields to the mysql table or modifying it outside of the GRANT or REVOKE statements? Obviously I don't want to make sure nothing will be affected by trial and error for these table.
View Replies !
View Related
Ordering Inserted Database Values
I need to add shirt size info for new T-shirts into a mysql database in this order: S, M, L, XL, creating the following table: itemNumber size inStock 1000 S Y 1000 M Y 1000 L N 1000 XL Y etc... Now, when I read the data back out, it'll be presented in logical order. My queries are in sequential order by size, as follows: Code:
View Replies !
View Related
Value Inserted Into MySQL Is Lost
Everything is getting passed to the database fine except for 'new_picorder' which, when printed to the screen the numbers are correct, but it is passed to the database as '1.' So here's the deal: I have four form fields that I am passing from my form to this script: total_images (the total amount of images being updated), propertyid (the property for which the images are being updated), old_picorder (the old order in which these images would be displayed), and new_picorder (the new order). Code:
View Replies !
View Related
Randomised Numbers Inserted In MySql
I would like a script that takes a base number of 100 and randomises it into 18 numbers (range of 0-10) which all add up to the 100. Whole numbers please. Examples: 4,7,9,2,1,6,5,8,10,1,7,3,8,7,2,7,4,9 == 100 7,3,8,7,2,7,4,9,1,10,8,5,6,1,2,9,7,4 == 100 I have no idea on how to create this, anyone have a script or ideas on the code? The random numbers will fill in fields on a player charactor statistics. The player will have stats, which at the start of the game will be filled in by random numbers. The user will have the option to reroll and the stats will be filled in my different numbers. Once they are happy, they click OK and the numbers are inserted into a database in different fields. 1. The Base Number is the total of the 18 variables, meaning all 18 have to addup to 100. 2. The numbers can be reused as many times as needed. 3. Numbers that are left over have to be added to the variables to make the total equal 100. 4. 0 is not really necessary, so the variables have to be 1-10 5. The idea is the player will click a button which will populate the fields, if the player wants to 'reroll' he clicks the button again and the fields get populated with different numbers.
View Replies !
View Related
HTML Inserted From MySQL Field
I am creating a website for a group and there is a linik to a meetings page. This page summarizes the agenda of the meeting. This would be entered into mySQL via a text area or something along those lines. Now, sometimes there may be a power point file they would like to include. What I want to do is create another text area, where the user can put in something like so: <A HREF="meeting.ppt">BlueTooth Meeting</A> and when I retrieve this from the database I want this html to be executed. Then that way all they have to do is simply place the *.ppt into the dir via ftp. Will this work?
View Replies !
View Related
How To Alet User If MySQL Data Inserted Is Not Unique.
Currently, if someone enters data in a unique column that is not unique, it just looks like it was inserted, but it wasn't. How do I do something like this: if ([Data inserted] is not unique){ echo '' } I know I could do a foreach loop and check it against every value, but since MySQL already knows it's unique, how do I tell this to the user?
View Replies !
View Related
Database Tables
I am trying to design a web based staff rota for my office. I'm going mad trying to design and relate the tables to one another. I've attached a picture of what I am trying to achieve and the tables I've come up with so far. I can relate 'employees' to the 'shift patterns' tables by the 'id' column in each table, but I cannot work out how to relate the 'employees' & 'shift patterns' tables to the 'date' table. For info: The entries 'N' 'E' & 'L' relate to the shift the employee is working on the specified date. (N=Night shift, E=Early Shift, L=Late Shift).
View Replies !
View Related
Search All Tables In A Database
I want to make a query that searched for a key word in every table from a database, I'm using: "SELECT * FROM * WHERE ..." and then I proceed to add all the field names of every table in the database but it doesn't seem to work, does anyone know how to work something like this?
View Replies !
View Related
Database Abstraction With Objects - What To Do With Look Up Tables?
I am coding a site in PHP and I have build an object structure for my database. What do I do about look up tables? For example.. I have a user and a status lookup. The status_id is in the user table. Do I write a whole class for the status table? That seems a bit silly since the data never changes... so how do I handle that? I don't want to digress to a simple SQL call in my app.. but that looks like the easiest.
View Replies !
View Related
Loading Database Tables With Filenames
What's the best method to use if you want to extract information from files in a directory, and then store the extracted information and file names in a database? Let's say you have some articles, and in the article text files you have tags for the author and title of the article. You want to make a dynamic navigation system so that users can read those articles, and select how they want them displayed (by author name, alphabetical by title, even by genre or other indexes if you added such information to the files). You need to keep the Author, Title, and Filename (including directory path) linked with each other, of course. But how to do this? Loop through each file, preg_match() the text (author's name) that you want to extract, and then load that into an array? Do that again for the title? And then again for the filename? Do you even need to store this info in a database, or would you make html links just from reading the files?
View Replies !
View Related
Big Database: Many SQL Tables Vs. Object Serialization
I'm building a PHP+MySQL application for a large website, with 100.000+ records in the main table, each one with a lot of dependencies in other SQL tables. Thus each page view requires many SQL queries and/or joins. Since I want to optimize performance, I'm wondering whether it would be better to serialize full objects instead and store them in a single table's TEXT field. This way I could just retrieve the row and unserialize it, avoiding other queries. So far this is my comparison: Pros: - only one query per page view Cons: - not only a bigger database, due to serialization overhead, but a single HUGE table (does this slow down things more than doing many queries?) Of course there are other drawbacks I actually don't care, such as getting a very PHP-specific database or limiting retrival to IDs. Does anybody have any advice about this? (Other than "try and benchmark it" :->)
View Replies !
View Related
Altering Tables In Database Through Php Code
i am writing code for a software for manging staff of a clinic.. and i want that as soon as i insert a new staff a new field to be created in one of the database table. One, more thing i want to know is that, that in my software i even want to add data to the fields code will be creating...so how should i write the code for creating fields by altering table and how to use these fields in database.
View Replies !
View Related
Pull From Multiple Database Tables
In table one is a list of names, name_1, name_2, name_3, ... In the second table their are photos related to each name. Some names have multiple photos, some names have none. The correct photo for each name will be marked as "selected". So for example, SELECT photo_name FROM $table2 WHERE name = 'name_1' AND photo = 'selected' What I want to do is create a page listing 50 names and each name will have the selected picture next to it if it exists, but the only way I know how to approach this would be to run a query on table 1 once and 50 queries on table 2. $result = mysql_query( "SELECT name FROM $table1" ); while( $row = mysql_fetch_array( $result ) ) { $query = "SELECT photo_name FROM $table2 WHERE name = 'name_1' AND photo = 'selected'"; ... } This seems highly inneficient and I know their has to be a better way to approach this. Any help or links to a good tutorial.
View Replies !
View Related
Database Design - Best Way To Link Tables?
I have a table "account" that stores my users accounts. Each user may add one or multiple paypals, bank account, credit card, and so on. Let's name the tables "paypalAccount", "bankAccount", "creditcards". The tricky point is that I need to store their ID's in a column (linkID) of a table (in this case the table "deposits"). What is the best way to link theses tables?
View Replies !
View Related
Updating Only Some Records Of Some Tables Of A Database
I manage a couple of mysql databases that are hosted on my server as well as at my ISP. We do update quite often some records in different tables & databases. As in South Africa, we pay per GB of traffic, complete dumping of all databases every day is excluded. I am looking at a better way of only synchronizing the records that have been modified. In every table I created, I have a date_created & a date_modified, and of course everytime there is an automatic or manual update of the data, date_modified is updated. Code:
View Replies !
View Related
Display The Tables Of Current Database
i just write this script to display the tables of current database but this is not working: <?php include 'library/config.php' include 'library/opendb.php' $query="show tables as 'tables'"; $res = mysql_query($query); while($row=mysql_fetch_array($res)) { echo $row['tables'] }; include 'library/closedb.php' ?>
View Replies !
View Related
OOP Database Tables <-> Php Interface (semi LONG)
I'm trying to grasp OOP to build an interface using class objects that lets me access database tables easily. You have probably seen this before, or maybe even built it yourself at some point in time. I have studied some examples I found on the internet, and am now trying to build my own from scratch. I have made a default table class (DB_Table), a default validation class (Validator) which is an object inside DB_Table and my final database tables each get a class: e.g. User, UserProfile, Country, etc that extend the DB_Table class. Its something along the lines of (incomplete code, just for demonstration purpose): <?php class DB_Table { public function __construct() { // intialize object // initialize (common) validator $this->validator = new Validator( $this ); } public function loadData() { // get all data from record } public function saveData() { // save all data to record } public function __get( $field ) { // get object property } public function __set( $field, $value ) { // set object property } } class User extends DB_Table { public $dbt = DB_TABLE_USER; public $fields = array( 'id' =NULL, 'userType' =NULL, 'username' =NULL, 'password' =NULL, 'email' =NULL, 'active' =NULL, 'timeCreated' =NULL, 'timeActivated' =NULL, 'timeUpdated' =NULL ); public $fieldSpecs = array( 'id' =array( 'screenname' ='user id', 'type' ='int', 'autoinsert' =true, 'autoincrement' =true, 'static' =true ), 'userType' =array( 'type' ='tyniint', 'nodisplay' =true ), 'username' =array( 'screenname' ='username', 'type' ='string', 'unique' =true, 'required' =true, 'static' =true, ), // etc... ); } ?> It definately still needs a lot of tayloring for it to even work smoothly for straightforward DB tables. But besides that, a few future issues are bothering me already: For instance, take the class User: let's say somebody registers at my site. This person fills in the details. The Validator class checks each field seperately. No problem. A new User record is inserted in the database. But what now, if a user wants to login to the system after the user is registrated? I would create an instance of class User. Asign the credential values to the object. And let the Validator class do its work again. But, if a user logs in with incorrect credentials, I don't want to report back to the user whether he/she filled in an incorrect username or an incorrect password. No, I only want to report back that he/she has filled in wrong credentials. But the Validator class only checks each field seperately. In order to keep the Validator class as common as possible would you build a seperate Login class for instance? A class that has some custom validation methods? Or perhaps just insert custom validation methods in the User class? I myself just cannot seem to make up my mind in this case. Probably cause I'm still too inexperienced when it comes to OOP programming. A few other minor questions come to mind also: - My gut feeling tells me it is wise to make a reference to the Validator class inside DB_Table, e.g: $this->validator =& new Validator( $this ); .... because it only creates a single instance of the object, right? - And why can't I refer to a private variable in DB_Table from an extended class (such as User)? I would asume, that this private variable, declared in the parent object, is now a private variable in User also, no? - And last but not least, is there a way for me to access let's say User properties from the Validator class without having to pass $this as an argument to: $this->validator = new Validator( $this ); .... I know the following to be incorrect, but I was thinking of something like the keyword parent.
View Replies !
View Related
Logic Error - Tables Of Users From A Database
I have a page which displays a tables of users from a database and I on this page the user can select someone to remove from the database in order to do this they select the username from a listbox which only contains the userIds. When this userId is sent for processing I would also like to be able to send the related username without the user having to select it.
View Replies !
View Related
Search Query On Two Separate Database Tables
I am receiving unwanted cartesian results in my query. I'm hoping someone might be able to explain the best way to do what I'm trying to do, because I obviously don't how to do it correctly! I'm trying to build a search query over two separate databases on my server. The connections are open and working, but I'm not sure how to output the results into an array, etc. Here is an example of the code. assume there are no parse errors even if code below doesn't reflect it: <?php require_once('Connections/database_1.php'); ?> <?php require_once('Connections/database_2.php'); ?> $colname_search = "1"; if (isset($HTTP_GET_VARS['searchsite'])) { $colname_search = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['searchsite'] : addslashes($HTTP_GET_VARS['searchsite']); } $search1 = mysql_query("SELECT * FROM database_1.table_1 WHERE MATCH (column_1, column_2) AGAINST ('$colname_search' IN BOOLEAN MODE)") or die(mysql_error()); $row_search1 = mysql_fetch_assoc($search1); $totalRows_search1 = mysql_num_rows($search1); $search2 = mysql_query("SELECT * FROM database_1.table_2 WHERE MATCH (column_3, column_4) AGAINST ('$colname_search' IN BOOLEAN MODE)") or die(mysql_error()); $row_search2 = mysql_fetch_assoc($search2); $totalRows_search2 = mysql_num_rows($search2); >>>body <?php do { ?> [these results would be in a table] echo $row_search['column_1']; <br> echo $row_search['column_2']; <br> echo $row_search2['column_3']; <br> echo $row_search2['column_4']; <br> <?php } while ($row_search1 = mysql_fetch_assoc($search1) || $row_search2 = myslql_fetch_assoc($search2); ?>
View Replies !
View Related
Synchronizing Database Tables And Structures Automatically
I have multiple mySQL databases. One database is the main database and the others just mimic the same one but have different data. In other words, all the databases have the same tables and table structure but different data in the tables. The problem is that whenever I make a change to the main database, I have to change the others too because all the databases use the same PHP scripts. Is there a way to have all the databases update automatically whenever I change the main database? Just like how changing PHP include files affect all scripts using them, I'm wondering if there's a way to automatically update all databases at the same time after making changes to the main one.
View Replies !
View Related
MySQL 'SHOW TABLES' Doesn't Show Temporary Tables?
I have a function call which creates a temporary table in MySQL, and then a second function call which operates on that temporary table. I was hoping to do something like this in the second function call to ensure that the table was in fact actually created: if (mysql_num_rows(mysql_query("SHOW TABLES LIKE 'my temp table name'"))) // do something else //error However, apparently the MySQL SHOW TABLES statement doesn't show temporary tables. Is there another query that I can use to show temporary MySQL tables so I can do this check?
View Replies !
View Related
Can Php Rebuild That Database With The Data That's In The Tables And Feilds Automatically?
If I have a Mysql database set up with minimal data in the tables, then export the database. Can php rebuild that database with the data that's in the tables and feilds automatically? I'm working on a private projected, I'd like to create a php file that set up a database with about 4 tables, and fields that have a small amount of data into them. I understand I'll have to make the database first, set the user and password for it. After that, can php create the tables, fields and the data strings at one go?
View Replies !
View Related
Mysql And Tables.
I got a php file that imports it's info fram a database. And from that info it creates a table. This is for a game. And if it's more than one game running it creates another table below the first one. Like this: Code:
View Replies !
View Related
MySQL, 2 Tables
I have 2 tables, one of them is 'friends' another is 'users' I need to pull * from friends and attach 1 corresponding column from the users table to identify a picture. Tried this $sql = "SELECT msgs.pid, msgs.uid, msgs.run, users.di FROM msgs,users WHERE msgs.pid='$id'"; but thats doing some strange stuff.. any ideas?
View Replies !
View Related
Mysql To Tables
Basically I'm looking to a roster section of my site but looking to do it with the back of mysql. On the front end I'm looking to store a picture and a munch of txt. All seperated out into a table Lets say 2 rows with 2 coloms in the first row and one big one on the bottom. On the back end (where the user logs in with there user name and password I'm looking for them to be able to modfy just there section of output on the front end. (this I know how to do... just make a sql query for that user only ... Duh) Code:
View Replies !
View Related
Mysql: Get Max Id From Two Tables
mysql query to know the max id in two tables working: $m1 = $db->sql_fetchrow($db->sql_query("SELECT MAX(id) FROM users")); $m2 = $db->sql_fetchrow($db->sql_query("SELECT MAX(id) FROM users_temp")); $max = max($m1[0], $m2[0]); echo $max However...I would like to know if there is a short query to get the $max value
View Replies !
View Related
|