Jump to content

phpTrainee

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by phpTrainee

  1. Do you want to update the oldest row or all rows before that date? If you just want the oldest row: $row = mysql_fetch_array(mysql_query('SELECT dtime FROM table WHERE newstype=2 ORDER BY dtime LIMIT 1')); $time=$row['dtime']; mysql_query('UPDATE table SET newstype=3 WHERE newstype=2 AND dtime = '.$time.' LIMIT 1');
  2. Well then just make an update statement. $time = 'x date cutoff'; mysql_query('UPDATE table SET newstype=3 WHERE newstype=2 AND dtime <= '.$time);
  3. I don't get what you're asking. You want to update the oldest 2 to a 3 as soon as you add a new 2 row? // do whatever you need to insert your row if ($value==2) { $row = mysql_fetch_array(mysql_query('SELECT id FROM table WHERE value=2 ORDER BY id LIMIT 1')); $id=$row['id']; mysql_query('UPDATE table SET value=3 WHERE id='.$id.' LIMIT 1'); }
  4. This checks for 0s, null, false, empty arrays, empty strings, empty variables. if (empty($mysqlvalue)) { }
  5. You don't need to store the words in the database. Just create a function. Put this piece of code in your php page anywhere BEFORE you get the message. function censor($message) { $badwords = array('shit','hell','die','death'); foreach ($badwords as $badwords) { $message = str_replace($badwords, '', $message); } return $message; } And after you grab the message from wherever, call the function before displaying it. $message = "Hello shit oh shit what the hell this is shit day"; $message = censor($message); echo $message;
  6. $message = "Hello shit oh shit what the hell this is shit day"; $badwords = array('shit','hell','die','death'); foreach ($badwords as $badwords) { $message = str_replace($badwords, '', $message); } echo $message;
  7. There's absolutely no information about your site. There are no links besides the next and previous and upload. The whole thing looks like an unorganized photo gallery. How is your site different from motifake.com? Why should I visit your site? What makes it unique? These comments may seem harsh, but those are my first impressions. Everything looks like it come from montifake. If you want users, you need to give them a reason to come. Currently, I see no advantages you have over montifake.
  8. $pieces = explode(",", $message); $result = count($pieces);
  9. Try this. It strips html tags, finds a space after the number of characters and then finds the last word. $message = strip_tags($message); if (strlen($message) > 200) { $space = strpos($message," ",200); $lastword = $space -1; $message = substr($message, 0, $lastword)."..."; }
×
×
  • 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.