Is it possible to select one row in MySQL and then miss 4 rows and then miss 3 rows and then miss 5 rows and then loop this until the end of the table?
I have found some LIMIT and OFFSET tutorials online, they work but, are only good for one off set. I need multiple.
I currently have this setup to work in PHP but I feel my PHP code is bloated because I only know a basic way of achieving this.
My PHP code is as follows
$int_count = 0;
$result = mysql_query("SELECT * FROM guitar_tunings_chords WHERE note_id >= '27'");
while ( $row = mysql_fetch_array($result) ) {
if ($int_count == 0)$n_1 = ($row["note"]);
if ($int_count == 4)$n_2 = ($row["note"]);
if ($int_count == 7)$n_3 = ($row["note"]);
if ($int_count == 12)$n_4 = ($row["note"]);
if ($int_count == 16)$n_5 = ($row["note"]);
if ($int_count == 19)$n_6 = ($row["note"]);
if ($int_count == 24)$n_7 = ($row["note"]);
if ($int_count == 28)$n_8 = ($row["note"]);
if ($int_count == 31)$n_9 = ($row["note"]);
if ($int_count == 36)$n_10 = ($row["note"]);
if ($int_count == 40)$n_11 = ($row["note"]);
if ($int_count == 43)$n_12 = ($row["note"]);
if ($int_count == 48)$n_13 = ($row["note"]);
if ($int_count == 52)$n_14 = ($row["note"]);
$int_count++;
}
What I am trying to do is select only Major triad notes from the Major scale.
I need to be able to select a base note from a table and then select at 3 different intervals to create chords.
Update
$result2 = mysql_query("SELECT *
FROM `guitar_tunings_links`
JOIN guitar_tunings_chords ON guitar_tunings_links.".$funtion_string." = guitar_tunings_chords.note
WHERE tuning = '".$chrd_tn."'") or die(mysql_error());
while ( $row = mysql_fetch_array($result2) ) {
$bridge_note = ($row["note_id"]);
}/*
var_dump ($key_note);
var_dump ($bridge_note);
var_dump ($funtion_string);
var_dump ($chrd_tn);*/
// SELECT * FROM `guitar_tunings_chords` WHERE `note_id` >= 28 LIMIT 0,8
$result4 = mysql_query("SELECT * FROM `guitar_tunings_chords` WHERE `note_id` >= ".$bridge_note." LIMIT ".$tuning_capo.",8") or die(mysql_error());
while ( $row = mysql_fetch_array($result4) ) {
//Notes
$note = ($row["note"]);
// Replace # with z
$note = str_replace("#", "z", $note);
// Distinguish nut notes on or off
if (preg_match("/\b".$note."\b/i", $notes_array)) {
$n_nut_style = 'note_nut_on';
} else { $n_nut_style = 'note_nut_off';
}
// Distinguish fretboard notes on or off
if (preg_match("/\b".$note."\b/i", $notes_array)) {
$n_style = 'note_on';
} else { $n_style = 'note_off';
}
You have to apply this to your exact tables but it should work pretty good.
% 12 gives one complete cycle of skips, the -4 and -7 (and -0) is the internal offset within each cycle.