Jump to content

bschultz

Members
  • Content Count

    454
  • Joined

  • Last visited

Community Reputation

0 Neutral

About bschultz

  • Rank
    Advanced Member
  • Birthday 07/20/1974

Profile Information

  • Gender
    Male
  • Location
    Minnesota, USA
  1. I got it working...left the dollar sign out of the function call getplayer('qb1'); and then an if / elseif statement inside the function: if ($position == 'qb1') { $new_position = $qb1; } elseif ($position == 'qb2') { $new_position = $qb2; } Thanks....
  2. I've tried that...the echo of the sql shows the name is blank
  3. I have a php file with a bunch of variables declared. I now need a function to put data on a separate page that pulls variables from the required page. So, on the required page, I have a variable set like this: $qb1 = "John Doe"; The function on the new script is called like this: getplayer($qb1); I've tried this without the dollar sign in the function like this: getplayer(qb1); and then adding the $dollar sign in the rest of the function code...but it never populates the sql query correctly. I'm guessing this is a case for variable variables or something similar, but I don't know how to get the variable value from the required page. Any ideas? Thanks. Here's the code: <?php function getplayer($position) { // start function //$new_position = "$" . $position; $new_position = $position; $file = "their.php"; require "$file"; //echo $qb1; this displays the name John Doe...as $qb1 is declared in the required file $db_select_their = "bschultz_their"; $servername = "localhost"; $username = "user"; $password = "pass"; $dbname = "db_name"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM (select number as position_number, name as position_name, pronunciation as position_pronunciation, pos as position_pos, height as position_height, weight as position_weight, year as position_year, city as position_city, state as position_state, notes as position_notes FROM $db_select_their WHERE name = '$new_position') as position"; //$sql = "SELECT * FROM bschultz_their WHERE name = $new_position"; echo $sql; //exit; /* this displays this text... SELECT * FROM (select number as position_number, name as position_name, pronunciation as position_pronunciation, pos as position_pos, height as position_height, weight as position_weight, year as position_year, city as position_city, state as position_state, notes as position_notes FROM bschultz_their WHERE name = '') as position The name is empty */ $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "#: " . $position_number . " - Name: " . $position_name . ""; } } else { echo "0 results"; } } // end function getplayer("${$qb1}"); $conn->close(); ?>
  4. I'm replacing Wordpress with my own content management system. Wordpress is just too bloated for my liking. The url's for the mp3's are embedded into the stories. Our final Beaver Fever Friday of the year was yesterday. What a show. It's always nice to get to know these seniors over their careers. Here are the interviews if you missed them: Christa Benson - Track <a href="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/ChristaBenson.mp3">Christa Benson - Track</a><br /><br /> Cody Cook - MGolf <a href="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/CodyCook.mp3">Cody Cook - MGolf</a><br /><br /> There is NO VARIABLE in the database content. Here's what I need the code to look like Our final Beaver Fever Friday of the year was yesterday. What a show. It's always nice to get to know these seniors over their careers. Here are the interviews if you missed them: Christa Benson - Track<audio controls> <source src="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/ChristaBenson.mp3" type="audio/mpeg"> </audio> <br /><br /> Cody Cook - MGolf <audio controls> <source src="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/CodyCook.mp3" type="audio/mpeg"> </audio> <br /><br />
  5. I'm finally moving away from Wordpress. I've used a couple of different mp3 players in the past, and I need to figure out how to replace a link to an mp3 file or just some text with xxx.mp3 with an html5 audio player. The one plugin I used replaced all links with a player button...another plugin I used you only needed to have .mp3 at the end, and it would replace the text with a button player. I have a VERY hard time wrapping my head around regex. How can I accomplish these two scenarios with 1 regex? <a href=http://domain.com/soundfile1.mp3>Some File</a> and http://domain.com/soundfile1.mp3 Are both in the old Wordpress database. The plugin has a button to press to play the file. Both need to be replaced with this: <audio controls> <source src="http://domain.com/soundfile1.mp3" type="audio/mpeg"/> </audio>
  6. Here's the function... function media_shooter_date ($show, $date_of_directory) // show is daily or weekend...date of directory is the date to expect from the media shooter directory { $todays_dow = date('l'); // Sunday, Monday...etc if ($show == "daily" && $todays_dow == "Sunday") { $media_shooter_date_diff = "+1 day"; } if ($show == "daily" && $todays_dow == "Monday") { $media_shooter_date_diff = "+0 day"; } if ($show == "daily" && $todays_dow == "Tuesday") { $media_shooter_date_diff = "-1 day"; } if ($show == "daily" && $todays_dow == "Wednesday") { $media_shooter_date_diff = "-2 days"; } if ($show == "daily" && $todays_dow == "Thursday") { $media_shooter_date_diff = "-3 days"; } if ($show == "daily" && $todays_dow == "Friday") { $media_shooter_date_diff = "-4 days"; } if ($show == "daily" && $todays_dow == "Saturday") { $media_shooter_date_diff = "-5 days"; } if ($show == "Saturday" && $todays_dow == "Sunday") { $media_shooter_date_diff = "+6 days"; } if ($show == "Saturday" && $todays_dow == "Monday") { $media_shooter_date_diff = "+5 days"; } if ($show == "Saturday" && $todays_dow == "Tuesday") { $media_shooter_date_diff = "+4 days"; } if ($show == "Saturday" && $todays_dow == "Wednesday") { $media_shooter_date_diff = "+3 days"; } if ($show == "Saturday" && $todays_dow == "Thursday") { $media_shooter_date_diff = "+2 days"; } if ($show == "Saturday" && $todays_dow == "Friday") { $media_shooter_date_diff = "+1 day"; } if ($show == "Saturday" && $todays_dow == "Saturday") { $media_shooter_date_diff = "+0 day"; } if ($show == "Sunday" && $todays_dow == "Sunday") { $media_shooter_date_diff = "+0 day"; } if ($show == "Sunday" && $todays_dow == "Monday") { $media_shooter_date_diff = "+6 days"; } if ($show == "Sunday" && $todays_dow == "Tuesday") { $media_shooter_date_diff = "+5 days"; } if ($show == "Sunday" && $todays_dow == "Wednesday") { $media_shooter_date_diff = "+4 days"; } if ($show == "Sunday" && $todays_dow == "Thursday") { $media_shooter_date_diff = "+3 days"; } if ($show == "Sunday" && $todays_dow == "Friday") { $media_shooter_date_diff = "+2 day"; } if ($show == "Sunday" && $todays_dow == "Saturday") { $media_shooter_date_diff = "+1 day"; } return date('m.d.y', strtotime("$media_shooter_date_diff")). "\n"; }
  7. I have confirmed the date is correct... Here's the code: $this_show_date = media_shooter_date ("Saturday", "Saturday"); echo "This show date = $this_show_date\n"; /* // This is the old code...that does NOT check for the date $dir = "/showdownloads/MediaShooter/MediaShooterDrop/*Years\ of\ Hits*"; foreach(glob($dir) as $file) { $files = glob("$file/*.*"); foreach($files as $audio){ $file_to_go = str_replace($file,"",$audio); copy($audio, '/showdownloads/25Years/' . $file_to_go); } } */ $path = "/showdownloads/MediaShooter/MediaShooterDrop/"; $dir = new DirectoryIterator("/showdownloads/MediaShooter/MediaShooterDrop/"); foreach ($dir as $fileinfo) { //echo "$fileinfo\n"; if ($fileinfo->isDir() && !$fileinfo->isDot()) { if (stripos($fileinfo->getFilename(), "Years of Hits") !== false && stripos($fileinfo->getFilename(), "{$this_show_date}") !== false && stripos($fileinfo->getFilename(), 'revised') !== false) { $final_directory = $fileinfo->getFilename(); } elseif (stripos($fileinfo->getFilename(), "Years of Hits") !== false && stripos($fileinfo->getFilename(), "{$this_show_date}") !== false && stripos($fileinfo->getFilename(), 'revised') === false) { $final_directory = $fileinfo->getFilename(); } } } echo $final_directory; exit; $files = glob("/showdownloads/MediaShooter/MediaShooterDrop/$final_directory/*.*"); foreach($files as $audio){ $file_to_go = str_replace($file,"",$audio); copy($audio, '/showdownloads/25Years/' . $file_to_go); }
  8. Changing the code to replace strpos with stripos still didn't match anything.
  9. I'm trying to loop through a directory for subdirectory names. If a subdirectory matches needle and haystack...loop through that directory and proceed. Here's the code $this_show_date = media_shooter_date ("Saturday", "Saturday"); $path = "/showdownloads/MediaShooter/MediaShooterDrop/"; $dir = new DirectoryIterator("/showdownloads/MediaShooter/MediaShooterDrop/"); foreach ($dir as $fileinfo) { echo "$fileinfo\n"; if ($fileinfo->isDir() && !$fileinfo->isDot()) { if (strpos($fileinfo->getFilename(), "Years of Hits") !== false && strpos($fileinfo->getFilename(), "{$this_show_date}") !== false && strpos($fileinfo->getFilename(), 'revised') !== false) { $final_directory = $fileinfo->getFilename(); // does this match ALL of the following: Years of Hits, the date returned from $this_show_date AND contains the word REVISED } elseif (strpos($fileinfo->getFilename(), "Years of Hits") !== false && strpos($fileinfo->getFilename(), "{$this_show_date}") !== false && strpos($fileinfo->getFilename(), 'revised') !== true) { $final_directory = $fileinfo->getFilename(); // does this match ALL of the following: Years of Hits, the date returned from $this_show_date AND DOES NOTcontain the word REVISED } } } echo $final_directory; exit; // once $final_directory is set, the code will proceed By echoing the $filename, I get this: This should match 25 Years of Hits SATURDAY 1 07.21.18 1 for WMIS-FM only and 25 Years of Hits SATURDAY WITH REVISED HOUR 2 SEGMENT 1 07.21.18 1 for WMIS-FM only...but doesn't. Any ideas why? Thanks!
  10. Barand, Many thanks...I would NEVER come up with that. Very much appreciated!
  11. The more I think of this...that logic won't work either. What if a special show runs for 6 hours? That would never fall between start and end of any one show. That would fall somewhere between Show #1 and Show #3 Not going to lie...this is far and away above anything I've ever written before.
  12. OK...so I read up on multidimentional arrays. I'd say this is headed in the right direction...but how do I work the logic for if special starts BEFORE the PREVIOUS regular? $regular = array( array( "title" => "Regular #1", "start" => "2018-04-02 12:00:00", "end" => "2018-04-02 15:00:00" ), array( "title" => "Regular #2", "start" => "2018-04-02 15:00:00", "end" => "2018-04-02 18:00:00" ), ); $specialty = array( array( "title" => "Special #1", "start" => "2018-04-02 18:00:00", "end" => "2018-04-02 19:00:00" ), ); foreach ( $regular as $show ) { foreach ( $specialty as $special ) { if (strtotime($special['start']) > strtotime($show['start']) && strtotime($special['start']) < strtotime($show['end'])) { echo "$special[title] falls between start end end of $show[title]\n"; } } // end regular as show } // end specialty as special
  13. Finally had some time to work on this...I'm getting an undefined offset error. Am I even going in the right direction? Print_r shows me the two results...so the offset should work. $regular_starts = array("Regular Show #1" => '2018-04-02 12:00:00', "Regular Show #2" => '2018-04-02 15:00:00'); $regular_ends = array("Regular Show #1" => '2018-04-02 15:00:00', "Regular Show #2" => '2018-04-02 18:00:00'); print_r($regular_starts); $special_starts = array("Special Show #1" => '2018-04-02 14:00:00'); $special_ends = array("Special Show #1" => '2018-04-02 17:00:00'); $r = 0; // regular $s = 0; // special $how_many_shows = count($regular_starts); while ($r <= $how_many_shows) { foreach ($regular_ends as $regular) { foreach ($special_starts as $special) { if ($special <= $regular) { echo "Show " . $special_starts[$s] . "starts BEFORE the end of the " . $regular_starts[$r] . "...a change needs to be made\n"; } $s++; } $r++; } } // end while
×
×
  • 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.