Jump to content

Search the Community

Showing results for tags 'duplicate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 12 results

  1. Here's a line. I want to add 100 more of same lines and increment the page numbers as shown below. I know I can just manually add 100 lines but Is there a way to do this with PHP that would make it easy? Or is this more of a javascript thing? // original $page1 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=1">1</a>'; // new $page1 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=1">1</a>'; $page2 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=2">2</a>'; $page3 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=3">3</a>'; $page4 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=4">4</a>'; $page5 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=5">5</a>'; ...etc
  2. Hi, I need some help with the query to find duplicate rows on specific value. I have tried many queries, but I can't find it. For now I have this. My sql structure: id INT(11) NOT NULL AUTO_INCREMENT, vrijeme TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, pocetni_broj VARCHAR(55) DEFAULT NULL, zamjenski_broj VARCHAR(55) DEFAULT NULL, glavni_broj VARCHAR(55) DEFAULT NULL, postoji_zamjena INT(1) DEFAULT NULL, PRIMARY KEY (id) And my query is: SELECT * FROM zamjene_brojeva GROUP BY glavni_broj HAVING COUNT(glavni_broj) > 1 Thta is giving me all duplicate values in table. But how do I find duplicate values where column glavni_broj has value 966 45 19-68? I know that there is 4 rows with that value in glavni_broj. I have tried to put Where in that, but than query fails. Any ideas how to do it?
  3. I have a script that resizes and uploads an image. It works great. Now I would like to add a new function to it that will detect if there is a duplicate image already posted. If there is, it will not upload the image. I have found a script that has that function. I am just a little lost on how to incorporate that into my php code. Here is my image upload/resize code. if(Input::exists()) { if(Token::check(Input::get('token'))) { // Setting up image folders based on user id $userDir= 'images/'.$userid.'/'; if(!is_dir($userDir)){ mkdir('images/'.$userid.'/', 0775); } else { // Uploading image with resize and crop. if(isset($_FILES['image'])) { if (empty($_FILES['image']['name'])) { $error = 'Please choose an image!'; } else { function swapHW() { global $height, $width, $newheight, $newwidth; $tempHeight = $height; $tempWidth = $width; $height = $tempWidth; $width = $tempHeight; $tempHeight = $newheight; $tempWidth = $newwidth; $newheight = $tempWidth; $newwidth = $tempHeight; } function getOrientedImage($imagePath){ $image = imagecreatefromstring(file_get_contents($imagePath)); $exif = exif_read_data($imagePath); if(!empty($exif['Orientation'])) { switch($exif['Orientation']) { case 8: $image = imagerotate($image,90,0); swapHW(); break; case 3: $image = imagerotate($image,180,0); break; case 6: $image = imagerotate($image,-90,0); swapHW(); break; } } return $image; } $name = $_FILES['image']['name']; $temp = $_FILES['image']['tmp_name']; $type = $_FILES['image']['type']; $size = $_FILES['image']['size']; $ext = strtolower(end(explode('.', $name))); $size2 = getimagesize($temp); $width = $size2[0]; $height = $size2[1]; $upload = md5(rand(0, 1000) . rand(0, 1000) . rand(0, 1000) . rand(0, 1000)); // Restrictions for uploading $maxwidth = 6000; $maxheight = 6000; $allowed = array('image/jpeg', 'image/jpg', 'image/png', 'image/gif'); // Recognizing the extension switch($type){ // Image/Jpeg case 'image/jpeg': $ext= '.jpeg'; break; // Image/Jpg case 'image/jpg': $ext= '.jpg'; break; // Image/png case 'image/png': $ext= '.png'; break; // Image/gif case 'image/gif': $ext= '.gif'; break; } // upload variables $path = $userDir . $upload . $ext; $thumb_path = $userDir . 'thumb_' . $upload . $ext; // check if extension is allowed. if(in_array($type, $allowed)) { // Checking if the resolution is FULLHD or under this resolution. if($width <= $maxwidth && $height <= $maxheight) { if($size <= 5242880) { // check the shape of the image if ($width == $height) {$shape = 1;} if ($width > $height) {$shape = 2;} if ($width < $height) {$shape = 3;} //Adjusting the resize script on shape. switch($shape) { // Code to resize a square image. case 1: $newwidth = 300; $newheight = 225; break; // Code to resize a tall image case 2: $newwidth = 300; $ratio = $newwidth / $width; $newheight = round($height * $ratio); break; // Code to resize a wide image. case 3: $newheight = 225; $ratio = $newheight / $height; $newidth = round($width * $ratio); break; } // Resizing according to extension. switch($type) { // Image/Jpeg case 'image/jpeg'; $img = imagecreatefromjpeg($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $thumb_path); break; // Image/Jpg case 'image/jpg'; $img = imagecreatefromjpeg($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $thumb_path); break; // Image/png case 'image/png'; $img = imagecreatefrompng($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagepng($thumb, $thumb_path); break; // Image/gif case 'image/gif'; $img = imagecreatefromgif($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagegif($thumb, $thumb_path); break; } try { $stmt = $db->prepare("INSERT INTO images(path, thumb_path) VALUES(:path, :thumb_path)"); $stmt->bindParam('path', $path); $stmt->bindParam('thumb_path', $thumb_path); $stmt->execute(); if($stmt == false){ $error = 'There was a problem uploading your image.'; } else { $success = 'Your image has been uploaded.'; move_uploaded_file($temp, $path); } } catch(Exception $e) { die($e->getMessage()); } } else { $error = 'Your image size is too big.'; } } else { $error = 'Your image resolution exceeds the limit.'; } } else { $error = 'Your have uploaded a forbidden extension.'; } } } } } } This guy has found a way to find duplicate images. Here is his script. http://www.catpa.ws/php-duplicate-image-finder/ I could really use some help on integrating his method into mine.
  4. hello .. I have 3 tables: student - infractions - Actions and view1 it Includes all tables and i make view1 source my page. my database structure: Table: student Columns: ID_student int(11) AI PK name varchar(45) Age varchar(45) Grade varchar(45) Table: infractions Columns: ID_infractions int(11) AI PK infractions_text varchar(45) ID_student int(11) Table: actions Columns: ID_Actions int(11) AI PK Actions_text varchar(45) ID_student int(11) view1 SELECT student.ID_student AS ID_student, student.name AS name, student.Age AS Age, student.Grade AS Grade, infractions.ID_infractions AS ID_infractions, infractions.infractions_text AS infractions_text, actions.ID_Actions AS ID_Actions, actions.Actions_text AS Actions_text FROM (student JOIN infractions ON student.ID_student = infractions.ID_student) JOIN actions ON student.ID_student = actions.ID_student php page code: PHP Code: </script> <?php } ?> <div class="ewToolbar"> <?php if ($Report1->Export == "") { ?> <?php $Breadcrumb->Render(); ?> <?php } ?> <?php if ($Report1->Export == "") { ?> <?php echo $Language->SelectionForm(); ?> <?php } ?> <div class="clearfix"></div> </div> <?php $Report1_report->DefaultFilter = ""; $Report1_report->ReportFilter = $Report1_report->DefaultFilter; if ($Report1_report->DbDetailFilter <> "") { if ($Report1_report->ReportFilter <> "") $Report1_report->ReportFilter .= " AND "; $Report1_report->ReportFilter .= "(" . $Report1_report->DbDetailFilter . ")"; } // Set up filter and load Group level sql $Report1->CurrentFilter = $Report1_report->ReportFilter; $Report1_report->ReportSql = $Report1->GroupSQL(); // Load recordset $Report1_report->Recordset = $conn->Execute($Report1_report->ReportSql); $Report1_report->RecordExists = !$Report1_report->Recordset->EOF; ?> <?php if ($Report1->Export == "") { ?> <?php if ($Report1_report->RecordExists) { ?> <div class="ewViewExportOptions"><?php $Report1_report->ExportOptions->Render("body") ?></div> <?php } ?> <?php } ?> <?php $Report1_report->ShowPageHeader(); ?> <form method="post"> <?php if ($Report1_report->CheckToken) { ?> <input type="hidden" name="<?php echo EW_TOKEN_NAME ?>" value="<?php echo $Report1_report->Token ?>"> <?php } ?> <table class="ewReportTable"> <?php // Get First Row if ($Report1_report->RecordExists) { $Report1->ID_infractions->setDbValue($Report1_report->Recordset->fields('ID_infractions')); $Report1_report->ReportGroups[0] = $Report1->ID_infractions->DbValue; $Report1->ID_Actions->setDbValue($Report1_report->Recordset->fields('ID_Actions')); $Report1_report->ReportGroups[1] = $Report1->ID_Actions->DbValue; } $Report1_report->RecCnt = 0; $Report1_report->ReportCounts[0] = 0; $Report1_report->ChkLvlBreak(); while (!$Report1_report->Recordset->EOF) { // Render for view $Report1->RowType = EW_ROWTYPE_VIEW; $Report1->ResetAttrs(); $Report1_report->RenderRow(); // Show group headers if ($Report1_report->LevelBreak[1]) { // Reset counter and aggregation ?> <tr><td colspan=2 class="ewGroupField"><?php echo $Report1->ID_infractions->FldCaption() ?></td> <td colspan=2 class="ewGroupName"> <span<?php echo $Report1->ID_infractions->ViewAttributes() ?>> <?php echo $Report1->ID_infractions->ViewValue ?></span> </td></tr> <?php } if ($Report1_report->LevelBreak[2]) { // Reset counter and aggregation ?> <tr><td><div class="ewGroupIndent"></div></td><td class="ewGroupField"><?php echo $Report1->ID_Actions->FldCaption() ?></td> <td colspan=2 class="ewGroupName"> <span<?php echo $Report1->ID_Actions->ViewAttributes() ?>> <?php echo $Report1->ID_Actions->ViewValue ?></span> </td></tr> <?php } // Get detail records $Report1_report->ReportFilter = $Report1_report->DefaultFilter; if ($Report1_report->ReportFilter <> "") $Report1_report->ReportFilter .= " AND "; if (is_null($Report1->ID_infractions->CurrentValue)) { $Report1_report->ReportFilter .= "(`ID_infractions` IS NULL)"; } else { $Report1_report->ReportFilter .= "(`ID_infractions` = " . ew_AdjustSql($Report1->ID_infractions->CurrentValue) . ")"; } if ($Report1_report->ReportFilter <> "") $Report1_report->ReportFilter .= " AND "; if (is_null($Report1->ID_Actions->CurrentValue)) { $Report1_report->ReportFilter .= "(`ID_Actions` IS NULL)"; } else { $Report1_report->ReportFilter .= "(`ID_Actions` = " . ew_AdjustSql($Report1->ID_Actions->CurrentValue) . ")"; } if ($Report1_report->DbDetailFilter <> "") { if ($Report1_report->ReportFilter <> "") $Report1_report->ReportFilter .= " AND "; $Report1_report->ReportFilter .= "(" . $Report1_report->DbDetailFilter . ")"; } // Set up detail SQL $Report1->CurrentFilter = $Report1_report->ReportFilter; $Report1_report->ReportSql = $Report1->DetailSQL(); // Load detail records $Report1_report->DetailRecordset = $conn->Execute($Report1_report->ReportSql); $Report1_report->DtlRecordCount = $Report1_report->DetailRecordset->RecordCount(); // Initialize aggregates if (!$Report1_report->DetailRecordset->EOF) { $Report1_report->RecCnt++; } if ($Report1_report->RecCnt == 1) { $Report1_report->ReportCounts[0] = 0; } for ($i = 1; $i <= 2; $i++) { if ($Report1_report->LevelBreak[$i]) { // Reset counter and aggregation $Report1_report->ReportCounts[$i] = 0; } } $Report1_report->ReportCounts[0] += $Report1_report->DtlRecordCount; $Report1_report->ReportCounts[1] += $Report1_report->DtlRecordCount; $Report1_report->ReportCounts[2] += $Report1_report->DtlRecordCount; if ($Report1_report->RecordExists) { ?> <tr> <td><div class="ewGroupIndent"></div></td> <td><div class="ewGroupIndent"></div></td> <td class="ewGroupHeader"><?php echo $Report1->infractions_text->FldCaption() ?></td> <td class="ewGroupHeader"><?php echo $Report1->Actions_text->FldCaption() ?></td> </tr> <?php } while (!$Report1_report->DetailRecordset->EOF) { $Report1->infractions_text->setDbValue($Report1_report->DetailRecordset->fields('infractions_text')); $Report1->Actions_text->setDbValue($Report1_report->DetailRecordset->fields('Actions_text')); // Render for view $Report1->RowType = EW_ROWTYPE_VIEW; $Report1->ResetAttrs(); $Report1_report->RenderRow(); ?> <tr> <td><div class="ewGroupIndent"></div></td> <td><div class="ewGroupIndent"></div></td> <td<?php echo $Report1->infractions_text->CellAttributes() ?>> <span<?php echo $Report1->infractions_text->ViewAttributes() ?>> <?php echo $Report1->infractions_text->ViewValue ?></span> </td> <td<?php echo $Report1->Actions_text->CellAttributes() ?>> <span<?php echo $Report1->Actions_text->ViewAttributes() ?>> <?php echo $Report1->Actions_text->ViewValue ?></span> </td> </tr> <?php $Report1_report->DetailRecordset->MoveNext(); } $Report1_report->DetailRecordset->Close(); // Save old group data $Report1_report->ReportGroups[0] = $Report1->ID_infractions->CurrentValue; $Report1_report->ReportGroups[1] = $Report1->ID_Actions->CurrentValue; // Get next record $Report1_report->Recordset->MoveNext(); if ($Report1_report->Recordset->EOF) { $Report1_report->RecCnt = 0; // EOF, force all level breaks } else { $Report1->ID_infractions->setDbValue($Report1_report->Recordset->fields('ID_infractions')); $Report1->ID_Actions->setDbValue($Report1_report->Recordset->fields('ID_Actions')); } $Report1_report->ChkLvlBreak(); // Show footers if ($Report1_report->LevelBreak[2]) { $Report1->ID_Actions->CurrentValue = $Report1_report->ReportGroups[1]; // Render row for view $Report1->RowType = EW_ROWTYPE_VIEW; $Report1->ResetAttrs(); $Report1_report->RenderRow(); $Report1->ID_Actions->CurrentValue = $Report1->ID_Actions->DbValue; ?> <?php } if ($Report1_report->LevelBreak[1]) { $Report1->ID_infractions->CurrentValue = $Report1_report->ReportGroups[0]; // Render row for view $Report1->RowType = EW_ROWTYPE_VIEW; $Report1->ResetAttrs(); $Report1_report->RenderRow(); $Report1->ID_infractions->CurrentValue = $Report1->ID_infractions->DbValue; ?> <?php } } // Close recordset $Report1_report->Recordset->Close(); ?> <?php if ($Report1_report->RecordExists) { ?> <tr><td colspan=4> <br></td></tr> <tr><td colspan=4 class="ewGrandSummary"><?php echo $Language->Phrase("RptGrandTotal") ?> (<?php echo ew_FormatNumber($Report1_report->ReportCounts[0], 0) ?> <?php echo $Language->Phrase("RptDtlRec") ?>)</td></tr> <?php } ?> <?php if ($Report1_report->RecordExists) { ?> <tr><td colspan=4> <br></td></tr> <?php } else { ?> <tr><td><?php echo $Language->Phrase("NoRecord") ?></td></tr> <?php } ?> </table> </form> <?php $Report1_report->ShowPageFooter(); if (EW_DEBUG_ENABLED) echo ew_DebugMsg(); ?> <?php if ($Report1->Export == "") { ?> <script type="text/javascript"> // Write your table-specific startup script here // document.write("page loaded"); </script> Showing page result : it Duplicate records !! ------------------------------------------------------------------------------- i need it to be like this : my database records : student table infractions-table: actions-table: please help me to find an amendment to the code Gratefully Report1report.php
  5. I can't figure out what's wrong with this. The program works, but the duplication doesn't work. The error I get is : Notice: Undefined variable: SongToAdd in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 64 Notice: Undefined variable: ExistingSongs in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line64 Warning: in_array() expects parameter 2 to be array, null given in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 64 Warning: fopen(SongOrganizer/songs.txt): failed to open stream: No such file or directory in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 72 There was an error saving your message! I bolded line 64 below, which is an if (in_array ) statement. line 64 is: if (in_array($SongToAdd, $ExistingSongs)) { echo "<p>The song you entered already exists!<br />\n"; echo "Your song was not added to the list.</p>"; } <?php if (isset($_GET['action'])) { if ((file_exists("SongOrganizer/songs.txt")) && (filesize("SongOrganizer/songs.txt") != 0)) { $SongArray = file("SongOrganizer/songs.txt"); switch ($_GET['action']) { case 'Remove Duplicates': $SongArray = array_unique($SongArray); $SongArray = array_values($SongArray); break; case 'Sort Ascending': sort($SongArray); break; case 'Shuffle': shuffle($SongArray); break; } // end of switch statement if (count($SongArray)>0) { $NewSongs = implode($SongArray); $SongStore = fopen("SongOrganizer/songs.txt", "wb"); if ($SongStore === false) echo "There was an error updating the song file\n"; else { fwrite($SongStore, $NewSongs); fclose($SongStore); } } else unlink("SongOrganizer/songs.txt"); } } if (isset($_POST['submit'])) { $SongToAdd = stripslashes($_POST['SongName']) . "\n"; $ExistingSongs = array(); if (file_exists("SongOrganizer/songs.txt") && filesize("SongOrganizer/songs.txt") > 0) { $ExistingSongs = file("SongOrganizer/songs.txt"); } } if (in_array($SongToAdd, $ExistingSongs)) { echo "<p>The song you entered already exists!<br />\n"; echo "Your song was not added to the list.</p>"; } else { $SongFile = fopen("SongOrganizer/songs.txt", "ab"); if ($SongFile === false) echo "There was an error saving your message!\n"; else { fwrite($SongFile, $SongToAdd); fclose($SongFile); echo "Your song has been added to the list.\n"; } } if ((!file_exists("SongOrganizer/songs.txt")) || (filesize("SongOrganizer/songs.txt") == 0)) echo "<p>There are no songs in the list.</p>\n"; else { $SongArray = file("SongOrganizer/songs.txt"); echo "<table border=\"1\" width=\"100%\" style=\"background-color:lightgray\">\n"; foreach ($SongArray as $Song) { echo "<tr>\n"; echo "<td>" . htmlentities($Song) . "</td>"; echo "</tr>\n"; } echo "</table>"; } ?> <!-- Display hyperlinks for the three functions in the switch statement (Sort Ascending, Remove Duplicates, and Shuffle) --> <p> <a href="SongOrganizer.php?action=Sort%20Ascending">Sort Song List</a><br /> <a href="SongOrganizer.php?action= Remove%20Duplicates">Remove Duplicate Songs</a><br /> <a href="SongOrganizer.php?action=Shuffle"> Randomize Song List</a><br /> </p> <!-- web form for entering new song names into the song list: --> <form action="SongOrganizer.php" method="post"> <p>Add a New Song</p> <p>Song Name: <input type="text" name="SongName" /></p> <p><input type="submit" name="submit" value="Add Song to List" /> <input type="reset" name="reset" value="Reset Song Name" /></p> </form> Any help would be appreciated!
  6. call number date duration 19738424064 2012-05-01 09:04:17 0.008 19738424064 2012-05-01 12:01:52 0.072 19738424064 2012-05-01 14:27:30 0.004 19738424064 2012-05-01 14:28:02 0.004 19738424065 2012-05-01 14:14:17 0.02 19738424065 2012-05-01 14:28:24 0.008 19738424064 2012-05-02 09:20:19 0.004 19738424064 2012-05-02 09:08:04 0.048 19738424065 2012-05-02 09:21:33 0.072 19738424064 2012-05-02 14:16:54 0.028 how do I get json php and call number should not repeated and google api line graph to calculate the total call in hour 05-2012.txt
  7. Please look at the table data carefully. I need to delete the rows. I need urgent help..!! PFA...!! Table: CREATE TABLE IF NOT EXISTS `version` ( `nidt` varchar(11) NOT NULL, `noeud` tinyint(3) NOT NULL, `VERSION` float NOT NULL, `ETAT_FONCT` varchar(20) default NULL, `idnap` varchar(25) NOT NULL, `nidtint` bigint(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; For SAME nidt & SAME noeud, i would like to DELETE rows based on two condition: 1. If ETAT_FONCT = "OPERATIONAL" Delete REST ROWS EXCEPT HIGHEST Version 2. If ETAT_FONCT != "OPERATIONAL" DELETE Older verions Thanks in advanced for input. :)
  8. I have an array containing the users input of 14 strings, I want to search this array to find duplicates, but I'm not sure how to go about it efficiently... there isn't already a function that does this by any chance is there? Thanks
  9. hi guys I am i am sorry to be a bother but i am new to php and I am currently in the process of creating, login and register pages that store a users name and password in to a database but I am finding it hard to source any code to check if the name exists and if it does tell the user that it does and that they have to choose a alternative user name. The code I have for updating the database is: <?php extract ($_POST); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("firstone", $con); $username = $_POST['username']; $password = $_POST['password']; // just to show the collection and storage of information from the form mysql_query("INSERT INTO details (username , password) VALUES ('$username', '$password')"); echo "your account has been created click next to continue"; mysql_close($con); ?>
  10. Ok so basically I have created a simple blog for my website which does what I want it to do pretty much I'm having a problem with the date though If I echo the date out in to my page it just shows the main body of my content and not the actual date :/ the other problem is when I am echoing the blog into my page It is showing the same content two or three times instead of selecting the other content in the db I currently have two articles in my db but it will only show the article with the id of 1 instead of outputting id 1 and id 2 into there respective places on the page <?php $mysql = new mysqli('localhost', 'root', 'root', 'blog') or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT id, title, date, author, category, LEFT(body, 600) AS excerpt, body from posts ') or die('Problem preparing the query'); $stmt->execute(); $stmt->bind_result($id, $title, $body, $author, $category, $excerpt, $date); while($row = $stmt->fetch()) : $lastspaceindex = strrpos($excerpt, ' '); ?> <?php endwhile; ?> then where I am echoing them out here my code is <div class="extra-wrap"> <span class="text3"><a href="blog.php?id=<?php echo $id; ?>" class="link1"><?php echo $title; ?> </a></span> <div class="inner4"> <p> Posted by <b><?php echo $author; ?></b> in <b><?php echo $category; ?></b> </p> </div> </div> <div class="clear"></div> <div class="page2-box2"> <figure class="page2-img1"><img src="images/page2-img2.jpg" alt=""></figure> <div class="extra-wrap"> <?php echo substr($excerpt, 0, $lastspaceindex) . "<a href='blog.php?id=$id'>...</a>"; ?><br> <span class="text3"><?php echo substr() . "<a href='blog.php?id=$id'>Read More</a>"; ?></span> </div>
  11. Although there are many similar questions and answers here and i've tried my best to make it work but no luck. This is my code: $content = "Blah...blah...[image=1], blah...blah...blah...[image=2], blah...blah...blah...[image=1], no more..."; function get_image($content) { $stripper = $content; preg_match_all("/\[image=(.+?)\]/smi",$stripper, $search); $total = count($search[0]); for($i=0; $i < $total; $i++) { $image_id = $search[1][$i]; if($image_id > 0) { $image = 'This is an image: <img src="images/'.$image_id.'.jpg" />'; } $stripper = str_replace($search[0][$i], $image, $stripper); } return $stripper; } I want to remove the duplicate "[image=1]" and return: Blah...blah...This is an image: <image>, blah...blah...blah...This is an image: <image>, blah...blah...blah..., no more... or Blah...blah..., blah...blah...blah...This is an image: <image>, blah...blah...blah...This is an image: <image>, no more...
  12. In the code below I'm trying to make it so that when they submit a newfoldername if the username is already in the database it will just add that newfoldername to the NEXT NULL COLUMN. Stumped. Thanks for the help! global $user; $username = $user->name; $newfoldername = $_POST['newfoldername']; $query = "INSERT INTO folders (username, folder1) VALUES ('$username', '$newfoldername') ON DUPLICATE KEY UPDATE (NEXT NULL COLUMN)='$newfoldername'"; mysql_query($query) or die("Query: $query Error: ".mysql_error());
×
×
  • 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.