I'm trying to add content to Pages from separate data table…
-
I’m trying to add content from a separate datatable on the same database as my WP installation. (back story: I have four other instances of doing this via includes, and it all works fine.)
Starting with getting the single_tag_title of the Page, it prints correctly. I move on to the query, which works, and when I don’t have the $nameFull commented out, it prints every name in the datatable – {first name} space {last name}. That also means at some point it prints the name out in a way that matches $slug.
However, what I have in the IF isn’t executing, which tells me it’s not recognizing when $nameFull equals $slug.
$slug = single_tag_title(); echo $slug; $query = "SELECT * FROM a_playerRank"; $results = mysql_query($query); echo mysql_error(); while($line = mysql_fetch_assoc($results)) { $nFirst = $line['nameFirst']; $nLast = $line['nameLast']; $nameFull = "{$nFirst} {$nLast}"; // echo $nameFull if ($nameFull == $slug) { $nameFullpic = "{$nLast}{$nFirst}"; $phoneMobile = $line['phoneMobile']; echo '<div class="profileWrap">'; echo '<div class="playerImage">'; echo '<img src="/wp-content/gallery/'. $line['year'] .'_head_shots/' . strtolower($nameFullpic) . '.jpg"></div>'; echo '<div class="playerProfile">'; echo '<table>'; echo '<tr class="pHead"><th>' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</th> <th><span class="year">' . $line['year'] . '</span></th></tr>'; echo '<tr><td class="playerData">' . $line['height'] . ' '; if ($line['position'] == 'PG') {echo 'Point Guard';} elseif ($line['position'] == 'SG') {echo 'Shooting Guard';} elseif ($line['position'] == 'SF') {echo 'Small Forward';} elseif ($line['position'] == 'PF') {echo 'Power Forward';} elseif ($line['position'] == 'C') {echo 'Center';} echo '</td></tr>'; echo '<tr><td class="playerData">School:</td>'; if ($line['city'] !='') { echo '<td>' . $line['city'] . ' (' . $line['school'] . ')</td>'; } else { echo '<td>'. $line['school'] . ' HS</td>'; } echo '</tr>'; } }
I had a different query trying to narrow the results before collecting them:
$query = "SELECT * FROM a_playerRank WHERE CONCAT(nameFirst, ' ' , nameLast) = '$slug'";
That was giving me this error:
ILLEGAL MIX OF COLLATIONS (UTF8_BIN,NONE) AND (UTF8_GENERAL_CI,COERCIBLE) FOR OPERATION ‘=’
Any thoughts?
Thank you for your time.
- The topic ‘I'm trying to add content to Pages from separate data table…’ is closed to new replies.