function show_poet_information($db, $data) { $cUsers = new CUsers($db); echo '<div class="poet_info">'; echo '<div class="textblock">'; echo '<h3>Runoilijan tiedot</h3>'; echo '</div>'; // Get user ID. if (isset($data['id'])) { $id = mysql_real_escape_string($data['id']); } else { echo 'Käyttäjän ID:tä ei olla annettu!'; } $ret = $cUsers->getUserInfo($id); // Fields to add in form $fields = array('username' => 'Käyttäjätunnus', 'firstname' => 'Etunimi', 'lastname' => 'Sukunimi', 'city' => 'Kaupunki', 'homepage' => 'Kotisivu', 'birthdate' => 'Syntymäpäivä', 'email' => 'Sähköposti', 'num_poems' => 'Runoja'); // Count number of poems $cPoem = new CPoem($db, $_SESSION); if ($_SESSION['id'] == $id) { $ret[0]['num_poems'] = $cPoem->numPoems($ret[0]['id'], true); } else { $ret[0]['num_poems'] = $cPoem->numPoems($ret[0]['id'], false); } echo '<table>'; foreach ($ret[0] as $key => $value) { // Convert birthdate to correct format if ($key == 'birthdate' && $value != '') { $tmp = explode('-', $value); $value = $tmp[2] . '.' . $tmp[1] . '.' . $tmp[0]; } // Show only fields what are listed in array $fiels if (isset($fields[$key])) { echo '<tr>'; echo '<td>'; echo $fields[$key]; echo '</td>'; echo '<td>'; echo $value; echo '</td>'; echo '</tr>'; } } echo '</table>'; // Link back to poems echo '<div class="back_to_poems">'; echo '<a href="poet.php?id=' . $ret[0]['id'] . '">' . 'Takaisin runoilijan runoihin</a>'; echo '</div>'; echo '</div>'; }
function show_poet_info($db, $id) { require_once 'CPoem.php'; $cPoem = new CPoem($db, $_SESSION); echo '<div>'; $id = mysql_real_escape_string($id); // Show correct number of poems, eg. show total number // of poems in own page, others should see only number // of visible poems. if ($_SESSION['id'] == $id) { $numPoems = $cPoem->numPoems($id, true); } else { $numPoems = $cPoem->numPoems($id, false); } $q = 'SELECT firstname, lastname, city, homepage FROM rs_users ' . 'WHERE id="' . $id . '"'; $ret = $db->query($q); if ($db->numRows($ret) > 0) { $ret = $db->fetchAssoc($ret); echo '<p class="own_info">'; if (isset($ret[0]['firstname'])) { echo $ret[0]['firstname']; } if (isset($ret[0]['lastname'])) { echo ' ' . $ret[0]['lastname']; } if (isset($ret[0]['city'])) { echo '<br>' . $ret[0]['city']; } if (isset($ret[0]['homepage']) && $ret[0]['homepage'] != '') { echo '<br><a href="' . $ret[0]['homepage']; echo '">' . $ret[0]['homepage'] . '</a>'; } echo '<br>Runoja: ' . $numPoems . '<br>'; echo '<a href="rss.php?poet_id=' . $id . '">'; echo '<img src="graphics/rss.gif" class="rss"></a>'; echo '<br>'; // If we are on own page, then we show some useful // links too, eg. possibility to change our informations. if ($_SESSION['id'] == $id) { echo '<a href="edit_profile.php">Muuta tietoja</a>'; echo ' / '; echo '<a href="download.php">Lataa runot</a>'; echo ' / '; echo '<a href="remove_profile.php">Poista käyttäjätunnus</a>'; } } echo '</div>'; }