Jump to content

imgrooot

Members
  • Content Count

    271
  • Joined

  • Last visited

  • Days Won

    1

imgrooot last won the day on May 16 2018

imgrooot had the most liked content!

Community Reputation

1 Neutral

About imgrooot

  • Rank
    Advanced Member
  1. Ah yes this is a better solution. I've tested it and it works. Thanks.
  2. Well...that was simple and a quick fix. Works now. Thank you.
  3. I have a simply query where I want show how many unique contests are there. So if I have 100 entries in a single contest, then each entry row will have the same contest id in this example. So even though there are 100 entries, they all belong to the same contest id. That means the echo of $total_contests should be 1. But instead I am getting the same count as the entry rows, which is 100. What am I doing wrong? $global_user_id = 1; $count_contests = $db->prepare("SELECT COUNT(*) FROM entries WHERE user_id = :user_id GROUP BY contest_id"); $count_contests->bindParam(':user_id', $global_user_id); $count_contests->execute(); $total_contests = $count_contests->fetchColumn(); echo $total_contests;
  4. I should also mention that I was trying to make the grayed out disabled text into black color. Which is why it wasn't working for me. Seems like I can color the text any other color except black.
  5. Never mind. I was able to do it using this method. option:disabled { color: red; }
  6. I want to change the color of an option that's disabled. By default it's showing grey. <option disabled="true" class="disabled">Heading One</option> I tried using the "disabled" class to change the color but it doesn't work. But for some reason I can change it's size. Is there a way around this that would work in all browsers?
  7. I just looked those errors up and they have something to do with AdBlocker extension I have installed on the browser. I disabled the AdBlocker extension on that page and reloaded it. Now all the errors are gone. Which is great news.
  8. I am looking for a code where I can get a video URL from Youtube, Vimeo, Facebook and convert it to an embedded video to be shown on my site. I found a script that does that. It works fine. The only errors I get are in the inspect element window in the browser. Errors such as this. Failed to load resource: net::ERR_BLOCKED_BY_CLIENT googleads.g.doubleclick.net/pagead/id:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT static.doubleclick.net/instream/ad_status.js:1 This is the function to generate the embedded videos. Do the above errors matter if the videos show up and play fine? function generateVideoEmbedUrl($url){ //This is a general function for generating an embed link of an FB/Vimeo/Youtube Video. $finalUrl = ''; if(strpos($url, 'facebook.com/') !== false) { //it is FB video $finalUrl.='https://www.facebook.com/plugins/video.php?href='.rawurlencode($url).'&show_text=1&width=200'; }else if(strpos($url, 'vimeo.com/') !== false) { //it is Vimeo video $videoId = explode("vimeo.com/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://player.vimeo.com/video/'.$videoId; }else if(strpos($url, 'youtube.com/') !== false) { //it is Youtube video $videoId = explode("v=",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else if(strpos($url, 'youtu.be/') !== false){ //it is Youtube video $videoId = explode("youtu.be/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else{ //Enter valid video URL } return $finalUrl; }
  9. So then it would be like this? But If I am binding parameters, then I use the prepare/execute method yes? $find_entries = $db->query("SELECT entry_id, votes FROM entries WHERE votes = (SELECT MAX(votes) FROM entries)"); $result_entries = $find_entries->fetchAll(PDO::FETCH_ASSOC); if(count($result_entries) > 0) { foreach($result_entries as $row) { $entry_id = $row['entry_id']; $votes = $row['votes']; ?> <div> <?php echo $entry_id; ?> </div> <div> <?php echo $votes; ?> </div> <?php } }
  10. Perfect! That's exactly it. Here is my updated query with your fix. $find_entries = $db->prepare("SELECT entry_id, votes FROM entries WHERE votes = (SELECT MAX(votes) FROM entries)"); $find_entries->execute(); $result_entries = $find_entries->fetchAll(PDO::FETCH_ASSOC); if(count($result_entries) > 0) { foreach($result_entries as $row) { $entry_id = $row['entry_id']; $votes = $row['votes']; ?> <div> <?php echo $entry_id; ?> </div> <div> <?php echo $votes; ?> </div> <?php } }
  11. I have a table where I would like to find the maximum value from a certain column and retrieve a single result. But it doesn't seem to work properly. I don't get any errors. The issue is that it's retrieving the entry_id from one row and the votes from another row. But I would like the row with max value to retrieve the same row's entry_id. Here is my code. Can you see what's wrong with it? $find_entries = $db->prepare("SELECT entry_id, MAX(votes) as vts FROM entries WHERE votes > :votes"); $find_entries->bindValue(':votes', 0); $find_entries->execute(); $result_entries = $find_entries->fetchAll(PDO::FETCH_ASSOC); if(count($result_entries) > 0) { foreach($result_entries as $row) { $entry_id = $row['entry_id']; $votes = $row['vts']; ?> <div> <?php echo $entry_id; ?> </div> <div> <?php echo $votes; ?> </div> <?php } }
  12. imgrooot

    Is there a way to simplify this code?

    Yes this is what I was looking for. I'll give it a shot. Thanks you.
  13. Suere thing. Here is my code setup for sending emails. $from_name = 'MyWebsite'; $from_email = 'info@mywebsite.com'; $user_email = 'user@email.com'; $post_subject = 'Hello World'; $post_message = 'It was a dark and stormy night...'; // Multiple recipients $send_to = $user_email; // Subject $subject = $post_subject; // Message $message = " <html> <body> <p>{$post_message}</p> </body> </html> "; // To send HTML mail, the Content-type header must be set $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; // Additional headers $headers[] = 'From: '.$from_name.' <'.$from_email.'>'; // Mail it mail($send_to, $subject, $message, implode("\r\n", $headers));
×

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.