How Do I Prevent Mysql From Printing Redundant Records?
I have a very urgent question. I am using php and mysql.
Say I have a database full of names and email addresses. I want to do a query that when you type in the name or partial name, mysql will only show a name once, even if it is in the database 200 times. Then I want to click on that name and have mysql show the 200 email addresses associated with that name (which I know how to do). See below:
View Complete Forum Thread with Replies
Related Forum Messages:
Prevent Adding Duplicate Records
theres a XML file located on the internet. every week or so. this xml file gets updated with one or two new entry's. i have a php script which can read all the entrys i want from this xml file. and then put it into a database. the problem is say i run the php script again to update the database and add the new entry's that the xml file has. every thing gets added again. each time the script is run. the enter xml file entry's are added again. so the database get full with duplicates triplcate records ect ect. how would i go about preventing the same record being added over and over.
View Replies !
Printing Records
Anyone care to help me display records from a table? Each record, has a persons name, picture, birthday, favorite quote, nickname, hobbies etc. etc. etc. I'd be looking just to display, in alphabetical order, their image, and their name underneath it.
View Replies !
Printing Records With A Twist
I have a problem that I have been working on for weeks and I cannot get it to work. I thought someone might have done this or could be of assistance. I have name and football positions in a database. I want to retrieve those names print them on the screen. The twist is, I have a certain number of positions (3 QB, 4 RB, 6 WR, etc.). If I have only 1 QB I want to leave 2 blank lines before I print the RB position and if I have 2 RB, I want to leave 2 blank lines before I print the WR Position, etc. Name, QB Blank Line Blank Line Name, RB Name, RB Blank Line Blank Line Name, WR If anyone has a way to loop through the recordset and do these, I would really appreciate it. It is probably pretty easy but I am new at PHP and I have just not had any luck.
View Replies !
Insert A Page Break For Printing Purposes After X Records On Page.
I need to insert a page break for printing purposes after X records on page. I'm querying five diffrent records with 5 different results and displaying them like: $record1 $record2 $record3 and so on So I want to get total number of records which is pretty easy I just add all the totals let's call it $subtotal. Then I want a page break after every 20 records of the $subtotal. Is this possible?
View Replies !
Finding Redundant Code
It seems to be becoming ever more common that we are given immense heaps of code which the original programmer doesn't seem keen on working with for one reason or another. Redundant code has always been a problem, but some of these have gone OOP and the problem is now even worse: dozens of classes in separate files each with dozens of methods. It seems some developers are just throwing in every class they've ever written 'just in case'. Code:
View Replies !
Open Ldap Authentication Without Redundant Log-in
I'm bidding on a PHP intranet development contract. One of the specific requirements is that the app interface with the company's existing Open LDAP server for user authentication. On site users log-in to their terminals via the LDAP server. Remote users VPN via the LDAP server. Either way, the company uses one LDAP server to control all IT access points, not just their intranet. I'm new to LDAP. Based on what I've read so far, I'm 100% certain I could build an authentication mechanism that uses an existing set of LDAP users (or use the Apache mod_ldap_auth to require a valid user). However, the client doesn't want a redundant log-in. They want to log into their terminals in the morning. Then, when it comes time to use the intranet, they want it to recognize that they've already logged in, ascertain which group they belong to, and return only the appropriate content. I'm not sure I can do this. It would seem, based on my fractured understanding of it, that any LDAP bind requires already knowing the dn. The Apache mod_ldap_auth seems promising, but will it see that the person is logged into the system and count that as a valid user? If so, how can I tell which group the valid user belongs to for variable content/functionality? My previous authentication has always been with MySQL and session variables so I'm clueless. Can someone please shed some light or point me in the right direction?
View Replies !
How To Prevent Id Sequence Like 1,2,3,4,6,5 In Mysql ?...
sometimes in a mysql table after changing and adding few stuff in it using php, the id column doesn't display numbers in proper sequence for example 1,3,2,4,5,7,6....how to prevent this from happening ?
View Replies !
Function With Many Vars Or Lots Of Redundant Code?
What would be worse speed-wise: 1 - function with 20 input variables and 20 return variables. 2 - running the same 100 lines of code in 3 different places with minor changes to said 20 variables. My specific problem: I need to run up to three queries depending on a certain piece of dynamic data. The output of the queries varies widely, but the html framework to display the data is for the most part identical. So I need to be able to execute the html for each query individually. Should I just copy and paste the html framework into each query's while loop? Or should I put the html framework inside a function, and put the call to the function in the while loop? Does that make enough sense?
View Replies !
Site Management - Removing Redundant Files
The problem is this: even though I try to manage the release process, there are inevitably files (css/javascript/php/images/html) which drop off the map when a released project is actively being developed. Mapping the live site using a conventional web-crawler is not a very viable solution since some pages are only available via forms which update the system or links implemented via javascript. Since the stuff I work on is all Linux based, I could check the atimes on files - but my file syncing mechanism updates these - also its rather difficult to provide access to development/support staff to rummage about without root access but preserving access times. The only obvious solution is to check on access from the webserver logs - but that would need tools for the purpose - also, IIRC, the log contains the requested URL not the actual file (cf mod_rewrite).
View Replies !
How To Prevent MySQL Injection Attacks?
I've fully read http://us.php.net/manual/en/function.mysql-real-escape-string.php and I'm still confused. Everyone has their own "best practice" code and they're all different. I've done extensive googling and it's the same. This is a huge headache as everyone is acting like an authority.. This is what I'm planning to do for my script. Please let me know of any shortcomings. 1) [Example 1442 in link] - add mysql_real_escape_string to ALL MySQL queries. Would this be enough? It would seem this would catch anything. 2) $id = intval($_GET['id']) instead of a simple $_GET['id']. Would this be necessary if I do the previous prevention method (1) and is there some code that be used if the variable passed is a string?
View Replies !
How To Prevent Simultaneous Use Of A Form In A CMS And Mysql
I have developed a CMS system with Php and Mysql. As more people are working on it simutanaeously, there is the danger that two users have the same html form on the screen, and one user changes fields, while the other is then working on old information. When this latter submits, he will destroy the changes that the first user made. Is there a neat way to prevent this? Blocking certain pages, making a warning? How does that work in PHP and/or Mysql?
View Replies !
Redundant Data Display Based On Multi-value Fields
I have a website where I want to send an email out to a bunch of users of all the new content posted that day. My content is tagged in different genres or groups. A piece of content can have multiple tags. So an example would be that my content is called "Video Program A" and it has been tagged in the vocabulary "Genre" as "Horror" and also as "Narrative". So in my email, if a piece of content has been tagged more than once, all the other fields get printed out multiple times, too. How can I make it so that even if the there are multiple termname and vocabname data, the rest of the data (title, description) only gets printed out once? Code:
View Replies !
Prevent Users From Requerying The MySQL Database.
I am building a simple forum/disussion area for a website. When a user posts a new message, they type info into a FORM which opens another page that queries the database (performing an INSERT INTO... statement). This works fine... However, if the user RENEWS the final page in their browser, the database is requeried with the same information that was posted from the FORM! (Thereby storing repeat information) How can I prevent this?
View Replies !
Printing From A Mysql Database
I am a newbie to PHP but have been set a task to use the MYSQL database I have created and be able to print information from it using PHP but the problem is I amnot sure where to start.
View Replies !
C Function In Php To Do Printing Of Data Taken From Mysql?
how to call C function in php to do printing of data taken from mysql? I have written a php personnel program and I need to printing by Browser (user) over the internet. I understand PHP cannot to real printing --correct me if I am wrong -- ( good for paperless concept). But I really need to doing for some integration of C programming- at the I will learn C programming myself via text.
View Replies !
MySQL Result Printing In For-loop
I have a script that count and print every week in a selected year. Now i want to connect this to the returned result from a MySQL query. Code to explain what I am trying to accomplish: Code:
View Replies !
Printing Pdf Documment From Mysql Table
I am trying to print a catalogue from a mysql table. I want it to print 6 products per page and then automaticcaly do the next page, until it is completed is this possible The first bit of code is the code to print the catelog, and the second is the include file that it uses:
View Replies !
PHP/MySQL Records Per Row
Is there any way to have the records pulled from a mysql database display like this in a table: record1 | record2 record3 | record4 etc: I've been thinking about this for about three months and have yet to come to a good solution.
View Replies !
How Many Records Can MYSQL 4.1.14 NT Via TCP/IP Can Hold?
how many records can MYSQL 4.1.14 NT via TCP/IP can hold? how many records per table can MYSQL 4.1.14 NT via TCP/IP can hold? how many records in a table can MYSQL 4.1.14 NT via TCP/IP can hold given the table has a field Primary key - BIGINT(20) autoincrement? need your opinion..Here are the facts: MY system is an internal one. My Server--Is only a Desktop.. Celeron 2.8 Gigahertz, 40Gig Baracuda HD, 512 MB memory.. And it serves an average of 20 users a day and it also serves me for my system development..The average records inserted per month on mYSQL is 10,000 records..We foresee that system would be used for about 10 years.
View Replies !
Counting Records In MySQL
I've been trying to write a page that checks the database and counts the number of records and if the number is less than 3000, it loads page X, but if the number is equal to 3000, it loads page Y. I know this should be a simple if/else statement but it's the checking and counting that I cannot get to work.
View Replies !
Display Records In Php/mysql
i have the mysql database with the name "wwwgosc_ton" and table with 17 field by the name "general". i want to dispaly all the records with 3 to 4 fileds and link each row to detail of the full field of that perticular records. Code:
View Replies !
Ordering Records Php/mysql
I'm trying to change the order records, via links on a php page. my code: $numID = $_REQUEST['id']; $numPos = ($_REQUEST['Pos']); if($numPos > 1){ mysql_query("UPDATE FamilyPhotoAlbum SET DisplayOrder = DisplayOrder - 1 WHERE Id = " . $numID); $numCounter = $numPos;.. I think my logic is a little off here. I can't seem to get the records to order correctly with out it skipping numbers.
View Replies !
Pagination Of MySQL Records
Data is being passed to page and being displayed in a dynamic table (Adjusts based upon the number of records to display.). Table row colors alternate; gray - white - gray. In addition, the <thead> is set up to allow for ordering of records. Now I want to add pagination; limiting the number of displayed rows to 20. Code:
View Replies !
Insert Records To MySQL
When I use the script below it doesn't insert the record into MYSQL database. I have checked the fields in the form and they are showing fine and the database is connecting without a problem. Does anyone see anything wrong with my script? $sql = mysql_query("INSERT INTO customers ('client name', 'bill to address', 'shipping address', 'phone', 'contact name') VALUES ('$clientname', '$billtoaddress', '$shippingaddress', '$phone', '$contactname')");
View Replies !
Displaying Mysql Records:
I wondered if anyone could offer some guidance, I trying to write a php script to connect to a database, and display the records in a table. I found the code here in a php4 text, and when I run this directly through the php intrupeter, the line Successfully connected is display and 4 as the number of rows. The database table we connect to, has three field username, firstname, surname. When I tried a while loop, to display the data in a table. No values were displayed. Could anyone possibly demonstrate how to display the username, firstname, surname values in a basic table? <?php function db_connect(){ global $MYSQL_ERRNO, $MYSQL_ERROR; $link_id = mysql_connect("localhost","user04", "password04"); if(!$link_id){ $MYSQL_ERROR = "Connection failed"; ..................
View Replies !
Replacing Records In Mysql
I have a web form for updating projects that feeds a bunch of mysql tables. The problem is that some of the fields on the form may generate more than one entry. So for example, I may have a project that is working into 5 countries. Code:
View Replies !
Updating Mysql Records
I have programmed the code to display the information of a particular person in the form so that he/she can change his/her details in the form and hence update his/her records.I have tried with the following code.It displays the form with the previous data. But when I submit,it blanks the fields (excepting the name,surname and dob which I have blocked from making any correction).The remaining 7 fields become blank with the last field's (ExamsPending) value to be zero. Code:
View Replies !
MySQL Consecutive Records
I have a table with columns like this: ob (datetime) temperature (float). There should be one record for each hour in a day (ob). I need to query this table and return a count of the number of consecutive records preceeding each hour within an 8 hour timeframe where the temperature > 70 degrees. I know how to get the number of records spread out during a timeframe, but I'm having trouble finding consecutive records.
View Replies !
Multiple Mysql Records
I am trying to develop a form which has the user inputing data in a columnar format. Each column has multiple fields (one for each row) there are 12 columns, I was able to submit to MySql database the first column fields. All subsequent columns would be the same field inputs but the values could be different. I need each column to be submitted to the database as a seperate record by using only one form submit.
View Replies !
Why Is My MySQL Table Building An "Overhead"/what Is That/how Can I Prevent It?
I hope you'll be nice to me and let this post go through even know its mysql and not directly php. But of course my script is php. The problem is, that my Table (1,8 MIO entries/100 MB/MyISAM) is not working anymore. Everytime my script wants to write in something the number of entries decreases, and at the "Overhead" column the number is growing. How can I make my table work without that overhead problem, without any further crashes and without loosing my data? If I use the repair or optimize function (phpmyadmin) the overhead is deleted, but the data is still lost, and the next time my script trys to put in something more entries will be deleted.
View Replies !
How Do Iterate Through MySQL Records And Displat Them?
Basically I have a page where a person can choose from a list of stories posted by people, or they can choose to submit their own. I've managed to do the page where they can submit their on. The way i did this was to set up a mySQL database, and table in the database called stories. I then made an id (primary key), author, title, body and date field in the table. When the user submits their story its given an id (which increments on each submition) and their author, title and body fileds are sent to the database. The date key is automatically stamped in. Ive also managed to have the submition page display what they submitted by using the count(*) function, their story would be the last to be submited , so it pulls that from the database and displays it. Now what I want to do - on the page where they can pick a story, is have the page connect to the database and grab each record and display the author and title on the page next to a radio button. And have the id for the story in a hidden field or variable so when the user to chooses a particlar story it uses the id to grab the story from the database. So how do iterate through all the records in the database, and display each one?
View Replies !
Problems Updating Records In MySQL With PHP
Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But not update. Here is a copy of the script I am using. I do not know what version of MySQL my host is running nor do I have Shell Access to it. I would like to setup a script so my website users can update thier records without my intervention. Also you may send replies to stevennyoung@yahoo.com Begin Script <?php $db = mysql_connect("localhost", "username", "password"); mysql_select_db("databasename",$db); if ($id) { if ($submit) { $sql = "UPDATE tablename SET EMail='$EMail',Username='$Username',Password='$Pas sword',Item= '$Item',Price='$Price',URL='$URL' WHERE Username='$Username'"; $result = mysql_query($sql); echo "table Updated."; } else { // query the DB $sql = "SELECT * FROM tablename WHERE Username='$Username'"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <form method="post" action="<?php echo $PHP_SELF?>"> e-Mail Address:<input type="Text" name="EMail" value="<?php echo $myrow["EMail"] ?>"><br> Username:<input type="Text" name="Username" value="<?php echo $myrow["Username"] ?>"><br> Password:<input type="Text" name="Password" value="<?php echo $myrow["Password"] ?>"><br> Item:<input type="Text" name="Item" value="<?php echo $myrow["Item"] ?>"><br> Price:<input type="Text" name="Price" value="<?php echo $myrow["Price"] ?>"><br> Item URL:<input type="Text" name="URL" value="<?php echo $myrow["URL"] ?>"><br> <input type="Submit" name="Update" value="Update table"> </form> <?php } } else { // display list of articles $result = mysql_query("SELECT * FROM tablename",$db); while ($myrow = mysql_fetch_array($result)) { printf("<a href="%s?Username=%s">%s %s</a><br> ", $PHP_SELF, $myrow["Username"], $myrow["Item"], $myrow ["URL"]); } } // Close DB Connection mysql_close() ?>
View Replies !
Grabbing Specific MySQL Records
I have set up a target page to pull information out of a mySQL database to populate the page. The problem is that it is only pulling from the first record and not the record specified. What do I have to do to pull from a specific record? I am using Dreamweaver MX to administer the site on WinXP using PHP if that information will help.
View Replies !
Sensible Method Of Inserting Records In To MySQL
I have users using a third party windows application. They can export data from this application directly to a text file (CSV). So far as I know, there is no way to make this application talk directly to the MySQL server. We're talking thousands of records here - it's not practical to have an HTML form handled by PHP which inserts the data to MySQL... or is it?? What I thought about doing was to have them export the data to the CSV file & then upload it to the web server using FTP. Once uploaded, I would have them go to a page with a PHP script which would run the command to import the data to MySQL. PHP can run shell commands, as I understand it from the manual. Perhaps this would be a bitch on Windows, though. Code:
View Replies !
& MySQL - Updating & Deleting Records
I am very new to MySQL and have built myself a small database for website update requests. The thing is Instead of having a "enter the record id # and press edit" I want to have a small edit icon at the end of each record I am displaying in a table. I've got the table data box setup at the end of the record and this is what I put in it: Code:
View Replies !
Very Slow MySQL SELECT Query After 11 Records
I have a very weird problem I moved my database to new IIS 6.0 + PHP 4.3 + MySQL 4.0 setup. I tried to check with myphpadmin if everything works fine, but I couldn't browse my table (125 records). I used SELECT option and found out that SELECT query up to 11 records is ok, but after that, even if I choose to limit query to 12 records, it just hangs. I tried selecting from the beginning of the table and from the middle - same thing, but when I run query localy on mysql console, everything works fine
View Replies !
Set Session Variables From Records In A MySql Database
I am working on a memebship section for a website and I am trying to set session variables from records in a MySql database when the user logs in. I think I am missing something because try as I might the just don't work! The sever I use had Glabal variables turned on, dont know if thats an issue in this case. Heres the code on the check user page:
View Replies !
Inserting Master-detail Records In Mysql
how I can insert a master-detail record in mysql? I use an auto-increment key, but I don't know how I can find that key for inserting the detail records, I tried to make a 'highest-key' function with 'select MAX(field)...' but in php it gives the wrong key (in mysql it gives the right one).
View Replies !
Changing Data In Objectified Mysql Records
I am using this very slightly modified function found here: http://us2.php.net/mysql_fetch_object to make mySQL rows into objects of type $classname: // This takes db result rows and makes real objects of $classname type function &buildObj($result, $classname) { while($row = mysql_fetch_assoc($result)) { if ($row === null) return null; /* Create the object */ $obj =& new $classname; /* Explode the array and set the objects's instance data */ foreach($row as $key => $value) { $obj->{$key} = $value; } $objs[] = $obj; } return $objs; } This is called by a retrieve: function: function retrieve($where) { echo $query = "SELECT * FROM $this->table WHERE " . join(' AND ', $where); $result = mysql_query($query); $rows =& buildObj($result, get_class($this)); mysql_free_result($result); return $rows; } The problem I am encountering is that if I do this in my script: $listing = new Listing; $listings = $listing->retrieve(array('row > 1') ); foreach ($listing as $aListing) { $aListing->address='xxxxxxxxxxxxx' } foreach ($listing as $aListing) { print_r($aListing); } The value in $aListing->address is unchanged. However if I do this: $listing = new Listing; $listings = $listing->retrieve(array('row > 1') ); foreach ($listing as $aListing) { $aListing->address='xxxxxxxxxxxxx' $newArray[] = $aListing; } foreach ($newArray as $aListing) { print_r($aListing); } I see the update values in $aListing->address .
View Replies !
Break MySQL Records Into CSS Columns Automatically
I'm making a page of links, each assigned a category. There are two tables - "favourites_links" and "favourites_categories". This is how the links currently appear: Category 1 Name Link 1 Link 2 Link 3 Category 2 Name Link 1 Link 2 Link 3 What I want to do is break my page into columns. Basically, set a number of columns (e.g. 3), count the total records, and work out how many records to show per column. Each column should be enclosed in a <div class="column"> wrapper, which floats to the left. Code:
View Replies !
Having Trouble Looping Through Records In A MySQL Table
I'm having some trouble looping through the records of a MySQL table using PEAR DB. Here is my code: $navigationSql = "SELECT * FROM nav"; $navigation =& $db->query($navigationSql); while ($navigation->fetchInto($nav)){ define("NAVIGATION", "<a href="$nav[2]" target="$nav[3]" title="$nav[1]">$nav[1]</a><br />"); } The when I enter: print NAVIGATION; into any of my PHP scripts it should loop through the stuff in table named nav, but it is only displaying the first record and so far everything I've tried does not seem to make it loop through all of the records in the table and I can't figure out why not.
View Replies !
Select Multiple Dates' Records From MySQL DB
I need to select multiple records from a MySQL DB based on one date value that I get from a form. When I get the date from the form I need to get the values for that date and for the six days before that to display the full week's data. Code:
View Replies !
MySQL Connection - Get Some Records And Print Them To The Browser
I have a script that works but it shouldn't, and I would like to know why. I originally wrote it with a statement to connect to the database, then there's a part to select the database, then I get some records and print them to the browser. It all works fine. A couple of months ago, I commented out the connection part (I can't remember why), and it still works. I had thought that there must be a connection statement.
View Replies !
|