Finding A Mysql Record
So when a client came to me and asked if I could create a website that would allow users to search the traceability details of his products, I rose to the challenge and said yes.
Let me exlpain further: The client produces a fish product, and has a simple (one table) database, with about 5 or 6 fields, that give details about the harvesting dates, the geographic origin, the batch number, etc. for each batch of fish.
I managed to create the table in a mySql database using phpMyAdmin. I also managed to create a set of "out-of-the-box" user admin tools for the client, by installing a free script (phpMyEdit I think). Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Finding A Row In A Record Set
how to find a particular row in a Recordset. Basically I have a bunch of IDs(auto number PK) from the database that I have in a certain order. They are in order because I have calculated the distance from a postcode to another postcode and are closest to furthest. I then use IN(123,67,34,89,234,...) in my SQL to bring back the records. What I need to do next is to loop through an array that I have that holds the IDs in the order I need and move to that rows ID in the record set. I would just like to know anyones advice on the best way to do this, there may be 10-100 users at any one time using the system. Is it quicker to query the DB for each individual ID? Things Ive tried. I have had success with using UNION in my SQL ie SELECT.... UNION SELECT.... UNION SELECT... etc for each ID. I have ruled out using Temporary tables because of the number of users. I am currently looking at using a function that I pass the record set and ID too, which then returns the row number in the record set.
View Replies !
Finding Most Recent Record
i have a login system, that logs the time of someones login, and gives it an id every page that is loaded, is loded with when, who etc. and a unique id. what i want to do is similar to what happens here. if a user is inactive ( not requests for 10 minutes) the log him out or something. i understand this would be a cron, but maybe it could be int eh page request, and simply checks and redirects if necicary.
View Replies !
Finding The Sum In Mysql
What would be the easiet way to add the values of a certain field in every record that it occurs in. For example, If a person is placing multiple orders on a website and each order is to be shipped to a different location. Each seperate order is being stored in the mysql db and I need to add the shipping costs of all orders together when the user is ready to check out.
View Replies !
Finding MySQL With 5.0.3
I have loaded PHP MySQL and Apache on windows in the past but recently had to reload my Win XP which is SP2 fully updated. Have reloaded Apache - fine - and MySQL and MySQLAdministrator - working fine Loaded PHP 5.0.3 and worked through configuring the ini to show a path to the ext file and so forth - copied some of the dll in the apache file. Copied many of the addtional modules in pecl into the php/ext directory and uncommented lots of them in the php ini (as suggested in a web tutorial - actually I don't NEED all of them yet) Installed PHPMyAdmin and configured that and then tried to connect but only get the error message that "cant find mysql" I tried this twice first with MySQLi and then MySQL set in the PHPMyAdmin configuration. Same result - some advice on a forum to a similar question suggested copying the dll files to the main php directory (just meant moving them up one in fact) and I did but that does not work either phpinfo shows lots of the modules but not MySQL or MySQLi I am rather puzzled - can anyone help this (long winded) problem?
View Replies !
Finding Lookup Fields In MySQL
I've got a lookup table for a lookup table and can't work out the SQL to do a search. Can anyone help? As an example, consider the following: Table 1 - books: fields: book_id, price, title, author data: 1, 2.99, 'Life', 'A. Slug' 2, 4.99, 'The Universe', 'A. Planet' Table 2 - book_fields: fields: field_id, field_name data: 1, 'cover_colour' 2, 'cover_type' Table 3 - book_field_lookup: data: book_id, field_id, field_value 1, 1, 'blue' 1, 2, 'hardback' 2, 1, 'blue' 2, 2, 'softback' How do I do all hardback books that are blue? I'm sure that the answer is simple, but have a block today :(
View Replies !
Finding Total Byte Size Of MySQL Query
I am working on an website messaging system. I want to be able to limit the amount of mail they can keep in their inbox. I want to do this by assigning them an amout of storage, but I need to calculate the total size of a MySQL query such as:
View Replies !
Getting One Record From MySQL
I am very new to php-mysql, and im a bit confused by all the tutorials which explain how to get records from mysql. In all the tutorials, they show how to recover all records from a table using a loop command. I have a mySQL table called news, which has headline and a body fields (as well as id). On my php page, i have two seperate tables. One I wish to print the info from one of the headline fields , and the info from the field body in the other. I don't wish to print all the records.
View Replies !
Add Record To Mysql Via Php
I am using Yahoo hosting. When I run my script, I get error on line 16, which is @ $db = mysql_pconnect(,'nitmal','xcxcxcxcx'); Should there be a parameter I need to pass before user name.
View Replies !
MySQL Next Record
Is there any easy way to see if there is a next or previous record in a MySQL table without looping through all the records? If I select a row, can I ask if there is a row before and/or after that row.
View Replies !
Best Way To Update A Mysql Record
I have a small app that a user can select an entry to be considered as "cancelled". This will change an entry in a mysql database. Is there someway of making a button that as soon as its clicked, sends the appropriate update info to the database and reloads the page?
View Replies !
Please Help With A Record Problem With MySql
I have php code that enters information into a mysql database. How can I make it so that the person entering the information has the choice for the listing to expire after a given number of days. Therefore I would like the record to become not active after this period.
View Replies !
Deleting Record From Mysql
I am just tring to delete on record based on a link generated. The link shows up, the number of the field is shown as deleted when the link is clicked, but the entry ios still in the db. Maybe a problem with how I have the db setup? I only have one field, add_manufacturers, and it is text. It is in a table called manufacturers. Code:
View Replies !
Accesing A Record In MySQL And PHP
I am accesing a record in a MySQL DB with the a sentence embeded in a php code. The result access a page like: http://www.mysite.com/page.php?id=16 where the id=16 indicates the id of the result. This work perfect, but I donŽt want the user to know that the number 16 correspond to a specified record. IŽd like to change the 16 for an algoritm. The algoritm result will be 16, but this will be only know by the database. As example, IŽd like that http://www.mysite.com/page.php?id=ewrefj34239dsa equals http://www.mysite.com/page.php?id=16
View Replies !
Record Expire PHP / MySQL
I created a database that lets people post a job opening. I thought of manually removing each entry after 2 months, but is there some code that can do this without me having to monitor the table?
View Replies !
Edit Mysql Record
I want to use a userform on a webpage so members can edit their data. Displaying the data on the form isn't the problem. But when members change their data how do i save then new data in their record. I dont want a new record.
View Replies !
Mysql Delete Record
when I run this code below it doesn't delete the record or display any error message $id = $_GET['id']; include("../dbconnect.php"); mysql_query("DELETE FROM promotions WHERE id='$id'") or die(mysql_error()); Such a simple thing to do but I don't no why it doesn't work
View Replies !
Mysql Record On Page
I'm trying to link to a specific record from one page to another. Let me try to explane: I have a homepage with some of the records of the latest news table + a link to "read more". I have the news page with all of the records of the latest news table Now when I click the read more link on the homepage I want to go to that specific record on the news page. I've tried to use printf ("<a href='http://www.crivic.com/latest_news/index.php?id=$rij[id]'>(read more...)</a>");
View Replies !
How To Duplicate Record In Mysql
Is there a simple select or subselect statemet that will duplicate a record from within a table. I tried some thing like this insert into howto select * from howto where howto_id=31; I think I am running into a problem because the howto_id is my primary key. Is there someway of doing this, simple. I could do it with PHP by calling that record and storing the variables and then inserting without the howto_id, but that seems expensive. Seems like there should be a simple sql statement to accomplish copying a record within your table.
View Replies !
Updating A Record In A MySQL DB
Maybe this is where i am going wrong, but I am using dreamweaver for this form. Right, made a form to insert a record into a mysql db. this works fine, no problem here. I then copied this form, and then modified it to an update form. The main difference is that that form text boxes are pre-populated from the database, thus allowing easy modifications. however, the box where I browse for the image is empty Code:
View Replies !
Updating A Record In A Mysql Database
I am sorry if this is a simple oversight, but I have been struggling for many hours over something which seems dead simple. I need to update a record in a table with more info. I am using the code below which soen't give me any errors but nothing happens. include("link.inc"); $db=connect_db(); $db_name=db_name(); mysql_select_db($db_name,$db); $sql="UPDATE data SET age='age',live='live',whatdo='whatdo',drinkalcohol='drinkalcohol',takedrugs='takedrugs',firstdrug='f irstdrug',seconddrug='seconddrug',medicine='medicine',alcohol='alcohol' WHERE id='$id'"; $result=mysql_query($sql,$db);
View Replies !
PHP-MySQL: Returning ID When New Record Is Made?
Let's say I create a new record in a table like this: mysql_query("INSERT INTO table (col1) VALUES ('example')",$conn); ....that had an auto-incrementing, unique identifying column named "ID" that would be populated with a unique number upon insertion... How can I get the unique number it assigned to that record returned for futher use?
View Replies !
Output Xml File From Mysql Record
how to get the record from databse directly..but now my application require me to output my record as xml output....so I really need help on it.../some guide ...this is what's my xml gonna be.. Code:
View Replies !
Applying A Class To The First And Last MySQL Record
I need to apply a class to the first and last records from a MySQL query. What I'm trying to do is pull the menus for my site but the first and last links need a class name for the design. I can't set them in the database because the order and items in the menu will change from time to time. so, here is how I pull my menu (cut down for this post). You can see it just grabs the name, url and makes a link. How would I apply a class to the first and last records? mysql_connect("localhost","root","password"); mysql_select_db("my_site"); $result = mysql_query("SELECT * FROM menu ORDER BY id"); while ($are=mysql_fetch_array($result)) { $name = $are['name']; $url = $are['url']; print '<a href="'.$url.'">'.$name.'</a>'." "; }
View Replies !
Inserting Unique Record MySQL
Are you able to check if a record that you are about to insert into one table isnt already located in another table? Obviously I can do a select query and check that way, however I am inserting multiple values in one statement and this is not efficient. The column is called "URL" in both tables and they are both set to unique. Can I somehow check if the value I am inserting is unique to both tables?
View Replies !
Checking For Existing Record In MYSQL
I've got a mysql database with a single table. I also have a page containing a FORM with a number of fields that once submitted is stored into the database. My problem is, users are able store the same information more than once. How do i check if that record already exists before inserting into mysql table? For example, I want to check that, that particular username, nickname and email exists in the table. If it does, print out a warning. If it doesnt exist, go ahead and perform the query and insert the record.
View Replies !
Return Record Ranking Of A Mysql Table
I have a table consisting of names, and registration dates. I query the db "select * from users order by regdate" I want do another query for a particular user, I am looking for the script to say: user is row 15 of 30.
View Replies !
Deleting A MYSQL Record From Within An Html Form
Just rebuilt an admin tool in PHP (originally built in asp) for a news section of a site. The problem is: My delete records php page is set out in an html form, with each news story expressed with a checkbox. normally i'd put a <a href="delete.php?id=<? echo $row->id; ?> </a> alongside the record, but i need to have it work in a form. What action should the form have, and how do i get the form to process the deletion process with the correct news story checkbox selected?
View Replies !
Mysql: Return A Record That Doesn't Contain Multiple Values?
This code doesn't appear to work : $q = 'SELECT ident, type, question, option1, option2, option3, option4, answer, stage FROM data WHERE type="test" AND ident!="'.$usedids.'" ORDER BY RAND() LIMIT 1' Now $usedids is simply "125,54,56,36" etc. Basically I am trying to put together a quiz. Now I am trying to get it to select a random question from the database. The hard part comes is not showing that question again. Once a question is displayed I am storing it in an array. Each time a question is displayed it is being added to the array. What I am trying to get it to do, is every time it selects a question it should pick one in $usedids(which is now a comma sepreated string".
View Replies !
Automatic Mysql Record Trigger Program
does anyone know of a "product" that monitors mysql inserts/deletes etc, and can trigger an event based on them? For instance, i have a database that is currenlty being used to track attempts at authentication. What i would like to do it trigger an email when the database see's an insert for a particular event.
View Replies !
Deleting A Mysql Record In Active Result
I'm doing a select in wich I retrieve some values. If the value is in an array, I must delete the record. As I'm doing a "mysql_fetch_object", may I delete this record inside the loop ? when doing a mysql_query, do I have a "local" copy or just a link to the mysql query result. In the first case I may delete the record as I get an "image" of the query result, in the second case I shouldn't as the query result will be changed by the deletion of any record.
View Replies !
Script Repeat Updates The Record And Also Inserts Another Record With The Same Information.
I have a form which contains some fields that are populated with data from a table. This same form also has fields that are empty because the data has not been collected yet. The main table is called client with a primary key of client_id. What I need to do with this form is select the client and update the record into a new table with the missing information. If the client doesn't not exist in this second table, I need to insert the row otherwise if the client does exist in this table because of a previous update, update the record. When I run my script, the insert works. When I try to run the script again and try to update the record, the script not only updates the record but also inserts another record with the same information. How can I write my script so it checks whether a client exists in a table and if it does, update the record and if the client does not exist in the table, add the client?
View Replies !
Inserts A Temporary Session Record In My MySQL Database.
I´m running a site with sessions. Everytime someone logs in, my script inserts a temporary session record in my mySQL database. It all works fine, but my problem is to remove them; I would like to remove all session records that haven´t been used for an hour. I know I could do this with a TIMESTAMP field, but everytime the user does something, goes to another page ect., I need to update that TIMESTAMP, but mySQL wont let me do that.
View Replies !
Assign Mysql Record Values To Gloabl Variabel
I've been struggle with the code below. I've tried mysql_fetch_assoc and various other functions, but can't seem to get it to work. The code works as far as that point though. global $first_name; global $last_name; global $password; function get_acct_rec($email){ $conn = db_connect(HOST, USER, PASS, DB, PORT); $sql = "SELECT * FROM `clients` WHERE `email` = '" . $email . "'"; $c_result = mysql_query($sql, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . db_error($conn)); while ($row = mysql_fetch_assoc($c_result)) { $first_name = $row['first_name']; $last_name = $row['last_name']; $password = $row['password']; echo $row['first_name']; } mysql_free_result($result); db_close($conn); }
View Replies !
MySQL INSERT Command Adding A Blank Record
I have a form that I am INSERTing into the MySQL database. I have the names and vaules set. The columns header is the same but when I "submit" the form it adds a blank record to the database. If I add another one, another blank record is added. Code:
View Replies !
Compare Record With Session Variable And Update Record If Different
I'm trying to figure out how to create a session variable from a recordset field value in a mySQL database and compare this with subsequent values from the same field each time the page reloads. When the value of the field changes (as a result of a user update) I want to trigger an event (redirecting to another page). It's probably a very basic PHP function but I am a newbie with this language.
View Replies !
Image Upload, Resize, Rename And Create Record In Mysql
I have limited knowledge in php and I am having trouble with uploading an image to a remote directory and resizing it if it's larger and renaming it to a unique id, while at the same time I would like to create a record in mysql database. I've tried to find some tutorials but I've had trouble finding any good ones. Wondering if anybody has good examples or link to a good tutorial.
View Replies !
Basic Php Mysql Knowledge, Setting Up, Adding Removing Record
i have an average knowledge but I have never got to a point connecting to mySQL and adding and removing a record. i have tried but have ended up getting confused... I understand SQL.. but i just don't get setting up a database and then connecting it using PHP and my mySQL is it possible someone could give me a simple explanation of how to set a mySQL database setup, login, add a record, and remove a record.. ?? im good at asp can connect to access easily and change data.. but i really want to get to grips with it using PHP and mySQL.
View Replies !
|