Ok so maybe I am just blanking out here but I am making a notification system and I am using PHP as my backend. I am using the following code to set up the correct number of notifications
$updates = mysql_query("SELECT * FROM updates WHERE userid = '$uid'");
while($row = mysql_fetch_array( $query )) {
if ($updates>0) {
for ($i=0; $i<$updates;$i++) {
echo '
<li class="update">'.$updates.'</li>
';
}
} else {
echo'<h4 class="nonew">No New Notifications</h4>';
}
}
This code will echo the correct number of notifications but will echo the entire where it supposed to echo that single comments content. How do I echo only the contents of that single notification? I am sure this has a simple answer and I already know it but I just can't think of it right now. Thanks!
EDIT:
Heres my database structure:
Updates
-id
-userid
-active
-date
-content
// In case $uid comes from user input
$uid = mysql_real_escape_string($uid);
// Fetch the user's notifications
$updates = mysql_query("SELECT content FROM updates WHERE userid = '" . $uid . "'");
if (mysql_num_rows($updates))
{
// Output the user's notifications
while ($get = mysql_fetch_array($updates))
{
echo '<li class="update">' . $get['content'] . '</li>' . "\n";
}
}
else
{
echo '<h4 class="nonew">No New Notifications</h4>' . "\n";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With