Jump to content

Search the Community

Showing results for tags 'duplicates'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 6 results

  1. I have some code where a user can enter a file name/number separated by a comma. At the moment, I am checking for duplicate entries against a MySql database, which works well. However, I also need a way to check if a user has input the same entry so upon submission, example, a1b2c3,a1b2c3. I can catch this and trigger or echo an alert and halt the execution of the script. If there are no dupe entries, proceed to check db. I have been struggling with this and need to find a way to check before the check db code.I turn to the exerts for some guidance/assistance with this. I would be grateful for any help with this so I can move forward and learn something new in the process. Many thanks. <?php if (isset($_POST['file_add'])) { if (!empty($_POST['file_add'])) { $filedata = split(',', $_POST['file_add'][0]); $fileadd = array(); $fileduplicates = array(); foreach ($filedata as $val3) { if ($val3 != "") { $sql = "SELECT custref FROM files WHERE custref='$val3' AND customer = '" . $_SESSION['kt_idcode_usr'] . "'"; $qry = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($qry)) { $fileduplicates[] = $val3; } else { $fileadd[] = $val3; $flag = 1; } } else { $fileerror = '<span style="font-weight:bold;font-size:12px;color: #ff0000;">' . 'FILE ERROR! ' . '</span>' . '<span style="font-weight:normal;color: #000;background-color:#ffa;">' . 'You must enter a file for intake' . '</span>'; echo "<script language=\"JavaScript\">\n"; echo 'alert("FILE ERROR:\nYou must enter a file for intake.");'; echo " </script>"; echo $fileerror; } } if (count($fileadd)) { echo 'You wish to add file(s): ' . ' <div style="word-wrap:break-word;white-space: pre-wrap;overflow:auto !important;height: 100px; width: 250px; border: 1px solid #666; background-color: #fff; padding: 4px;">' . '<span style="font-weight:bold;color: #000;">' . join(', ', $fileadd) . '</span>' . '</div> ' . ' <p /> '; //if(count($duplicates) == 0) // add to session only if we have no duplicates $_SESSION['file_add'] = $fileadd; /// change here, do not store $_POST since it can contain duplicates } if (count($fileduplicates)) { $filedupeerror = "ERROR:" . " " . "File" . " " . '(' . join(', ', $fileduplicates) . ')' . " " . "This file is already in the database"; echo "<script language=\"JavaScript\">\n"; echo 'alert("FILE ERROR:\nThis file is already in the database");'; echo " </script>"; echo $filedupeerror; } } } ?>
  2. hi I want to use url attachments for other post instead upload files again. Duplicate row(s) of attachments table with "attid field" posted from form and change a "postid field" in same table. I have a form with some input checkbox. The values of input are numbers which point to values of the field in database (attachments table > attid field ). <input type="checkbox" name="attid[]" value="10" /> <input type="checkbox" name="attid[]" value="250" /> This "attid" field is a Primary Key and AUTO_INCREMENT. I want when form submit, duplicate a row(s) with "attid" posted. Used this > INSERT INRO - SELECT query with loop by for each but not succesful $sql = ('INSERT INTO attachments (field1, field2) (SELECT * FROM attachments WHERE attid= :attid)'); thanks
  3. There is no great way for me eliminate duplicates upon entry. I can't just use first name and last name, because sometimes we have kids with the same name. I can't really use their school because sometimes the parents just use the school name, other times they put HS after it or High School, etc. So from year to year I get a lot of duplicate entries into my database. The problem arises for me when a kid is registered but doesn't pay right away, so mom or dad return to the site to pay, and instead of just paying they re-register. I'm trying to eliminate those. Of course when that is the case, they generate a new ID so I started there: select * from fallLeague10 as f1 join fallLeague10 as f2 where f1.nameFirst = f2.nameFirst and f1.nameLast = f2.nameLast and f1.confirm='1' and f1.id <> f2.id order by f1.nameLast, f1.nameFirst (confirm = they entered this year) I really can't make sense of why it's producing the list that it is. I'm not really getting duplicates, maybe a couple, but there are definitely non-duplicates in that list. Basically, what I'm looking to get is 8-12 names that show up twice (or three times in one instance). It's a 470 person lot, and I just want to make sure I don't miss any because my numbers have to be exact or some kid ends up on two teams. I figure a query would be better than scrolling through my list.
  4. Hello: I m having this foreach duplicated in returned data this happened when I upgraded to a news version of xammp and can t figure out why the duplicated are taking place... <?php if(isset($sess_uLOG) && $sess_uLOG==true) { $attrib = array('name'=>'fxxx','class' => 'fxxx'); echo form_open('main/profile',$attrib); ?> <ul class="cont_up"><!-- START section Overview--> <?php foreach ($u_profile as $u_pr) : ?> <li> <div class="sec_topic">Overview<span><?php $ubtn=array('name'=>'form_btn','value'=>'btn_save0','type'=>'submit','content'=>'Save');echo form_button($ubtn)?></span></div> <div class="profile_pic"> <img src="<?php echo base_url()."assests/imgs/profile/thumbs/".$u_pr->prof_pic; ?>" width="200" height="200" alt="<?php echo $u_pr->un; ?>"> </div> <div class="sec_content0"> <blockquote> <span>gender:</span><span> <SELECT name="ugender"> <?php @$u_gender=$this->input->post('ugender', TRUE); foreach ($ar_gender as $val_gender) { if ($u_gender != NULL && !empty($u_gender)) { echo "<option value='$val_gender'"; if ($val_gender == $u_gender) {echo " selected='selected'";} echo ">".$val_gender."</option>\n"; } else { echo "<option value='$val_gender'"; if ($val_gender == $u_pr->gender) {echo " selected='selected'";} echo ">".$val_gender."</option>\n"; }//END if else post } ?> </SELECT> <span>name:</span> <span> <input type="text" name="ufname" value="<?php echo isset($_POST['ufname']) ? $_POST['ufname'] : $u_pr->ufn; ?>" maxlength="12"> <input type="text" name="ulname" value="<?php echo isset($_POST['ulname']) ? $_POST['ulname'] : $u_pr->uln; ?>" maxlength="12"> </span> <span>username:</span> <span><input type="text" name="uname" value="<?php echo isset($_POST['uname']) ? $_POST['uname'] : $u_pr->un; ?>" maxlength="18"></span> <span>country:</span><span> <SELECT name="ucountry"> <?php @$u_count=$this->input->post('ucountry'); foreach ($country as $value) { if ($u_count != NULL && !empty($u_count)) { echo "<option value='$value'"; if ($value == $u_count) {echo " selected='selected'";} echo ">".$value."</option>\n"; } else { echo "<option value='$value'"; if ($value == $u_pr->u_country) {echo " selected='selected'";} echo ">".$value."</option>\n"; }//END if else post } ?> </SELECT> </span> <span>phone: +</span><span><input type="text" name="uphone" value="<?php echo isset($_POST['uphone']) ? $_POST['uphone'] : $u_pr->u_phone; ?>" maxlength="18"></span> </blockquote> </div> </li> <?php endforeach; ?> </ul><!-- END section Overview--> <?php echo form_close(); }else{ .... }
  5. Hey Guys! I've been trying to figure out how to tackle a solution for this, on the site you have a combobox to select a subject and add other fields aswell. My problem is if the subjects are the same group them together and only echo the subject once but echo the other fields aswell. if($execute){ $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $sthandre = $con->prepare("SELECT book.id, book.title, book.url, book.viewer, book.sub_id, subj.subject_id, subj.name FROM book LEFT JOIN subj ON(book.sub_id = subj.subject_id) WHERE book.username_id = :yourid ORDER BY subj.subject_id"); $sthandre->execute(array(':yourid'=>$userid)); while ($row = $sthandre->fetch()){ $bmid = ($row ['id']); $title = ($row ['title']); $url = ($row ['url']); $audience= ucfirst($row ['viewer']); $subid = ($row ['subject_id']); $subjectname = ($row ['name']); //somehow if the subject name is a duplicate echo it once and carry on with the other variables looping echo "$subjectname,$title,$audience" } } the current output; Subject | Title |audience ------------------------------------------------------ |Classic | The Who | Everyone| |Classic | The End | Mature | |Classic | Happy | Teen | |Other | Last | Everyone | what im hoping it to be; Subject | Title |audience ------------------------------------------------------ |Classic | The Who | Everyone| | | The End | Mature | | | Happy | Teen | |Other | Last | Everyone | it will be in another format its just easier to explain in a grid format. Thanks i appreciate it!
  6. Hey guys, really hoping someone can help me with this I'll be extremely grateful! I am redesigning a website with a news archive type page using the mysql database from the previous version. The archive section contacts mysql and returns a number of values. In the archive section the previous version of the site uses a column called newsTitle to put information into the anchor url of the page which displays the full article. The problem is that there are duplicates in newsTitle. The previous website dealt with this by using php to add a suffix to the 1st duplicate of -0 , a suffix to the second duplicate of -1 and so on. I want to recreate this so I can keep the urls the same for seo purposes, otherwise I would just use the unique column newsID to seperate each article. Here's a simplistic version of my code so far. If anyone can come up with a way to add the suffixes to $title I will be soooo happy! Really appreciate your time and assistance. mysql_connect($host, $user, $pass) or die ("Unable to connect!"); @mysql_select_db($db) or die ("Unable to select database!"); $querytable="SELECT * FROM tblnews WHERE YEAR(newsDate) >= $startyear AND YEAR(newsDate) <= $endyear AND newsPageID = 13 ORDER BY `tblnews`.`newsDate` DESC"; $result=mysql_query($querytable); $sql = "SELECT * FROM tblnews WHERE YEAR(newsDate) >= $startyear AND YEAR(newsDate) <= $endyear AND newsPageID = 13 ORDER BY `tblnews`.`newsDate` DESC LIMIT $offset, $rowsperpage"; $result3 = mysql_query($sql, mysql_connect($host, $user, $pass)) or die ("Unable to connect!"); mysql_close(); $i= ($currentpage - 1) * 4; while ($list = mysql_fetch_assoc($result3)) { $title=mysql_result($result,$i,"newsTitle"); $url = strtolower ($title); ?> <div id="release"> <p> </p> <h3><a href="questionsarticle.php?pagetitle=<?php echo $url; ?>"><?php echo $title; ?></a></h3> <p> </p> </div> <?php $i++; }
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.