Jump to content

Fenhopi

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

Everything posted by Fenhopi

  1. Thank you, man! How would I remove the - in front of number though? if($Time contains("-"){ Don't know how to post number without - symbol }
  2. Hi, I have a database where I store times with the Now(); function. What I want is: When the viewer looks at the post, instead of it saying: Posted: 2010-11-14 19:08:14, I want it to say posted: x hours ago, Posted: x days ago, etc. Any help with this would be appreciated!
  3. Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself).
  4. Thank you for replying! That messes up my script though, as in it doesn't get what's going on in the loop. I should post the whole script: This is the gethint.php: <?php include("include/session.php"); $GetNames = "SELECT firstname, lastname, username FROM users"; $GetNamesConnect = $database->query($GetNames); While($row = mysql_fetch_array($GetNamesConnect)) { $a[$row['username']] = $row['firstname'] . " " . $row['lastname']; } //get the q parameter from URL $q=$_GET["q"]; //lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint.", ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="no suggestion"; } else { $id = $row['username']; $response= "<a href='profile.php?user=$row['username']'>$hint</a>"; } //output the response echo $response; ?> And this is the form that retrieves the suggestions: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <script type="text/javascript"> function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","gethint.php?q="+str,true); xmlhttp.send(); } </script> </body> </html>
  5. Hi, This is a part of a script that suggests firstname+lastname when a user tries to search. What I'm trying to do is that the suggestions become links to the users profile, but then I have to get the username from the same row as each of the names it suggests. Here's my code so far: $GetNames = "SELECT firstname, lastname, username FROM users"; $GetNamesConnect = $database->query($GetNames); While($row = mysql_fetch_array($GetNamesConnect)) { $a[] = $row['firstname'] . " " . $row['lastname']; } //get the q parameter from URL $q=$_GET["q"]; //lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint.", ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="no suggestion"; } else { $response= "<a href=\"profile.php?user=(THIS IS WHERE I NEED THE USERNAME)\">$hint</a>"; } //output the response echo $response; ?>
  6. Hi, I'm trying to store the first+lastname from my mysql user datababase into arrays like this: // Fill up array with names $a[]="Anna"; $a[]="Brittany"; $a[]="Cinderella"; $a[]="Diana"; $a[]="Eva"; $a[]="Fiona"; $a[]="Gunda"; $a[]="Hege"; $a[]="Inga"; $a[]="Johanna"; $a[]="Kitty"; $a[]="Linda"; $a[]="Nina"; $a[]="Ophelia"; $a[]="Petunia"; $a[]="Amanda"; $a[]="Raquel"; $a[]="Cindy"; $a[]="Doris"; $a[]="Eve"; $a[]="Evita"; $a[]="Sunniva"; $a[]="Tove"; $a[]="Unni"; $a[]="Violet";
  7. Hi, I'm trying to build a notifier. I want the user to be able to pick a time between "some time" and "some time" on Mondays, where his notification will be showing between chosen time on every Monday for 4 weeks. First off how would I make a time drop down box, or something? I know how to get the date of all mondays for the next 4 weeks. But how would I get the notifier to know that it's that date and that time, and that he has to show the event for that time and that time only? All help appreciated.
  8. I have a function that's supposed to search through my user database and find the member the query was searching for. Is there a way to make it so that it suggests users while I'm typing?
  9. I have a form where you can pick all the days in the week. When the form is posted my code finds the date of the day you picked that most recently went by. Then the code takes that date, and echos the date of every day of the week that you picked that comes after that date for a year. But for some reason he thinks we're in 2009, even though i know the date puts out that we're in 2010. Here's the code: <?php //function if(isset($_POST['submit'])) { function nextWeeksDay($date_begin,$nbrweek) { $nextweek=array(); for($i = 1; $i <= $nbrweek; $i++) { // 52 week in one year of course $nextweek[$i]=date('d-m-y', strtotime('+'.$i.' week',$date_begin)); } return $nextweek; } //Get what user posted as day, and find the date of the past day gone. $roday = $_POST['day']; echo $roday; echo date('d-m-y',strtotime('last ' . $roday)); $sistdag = date('d-m-y',strtotime('last ' . $roday)); /// end function /// example of a select date // var $date_begin = strtotime($sistdag); //D Day Month Year - like function format. $nbrweek=52; // call function $result=nextWeeksDay($date_begin,$nbrweek); // Preview for($i = 1; $i <= $nbrweek; $i++) { echo '<br> - '.$result[$i]; } } ?> All help appreciated!
  10. Thank you very much! I get this error though:
  11. Hi, I have a select box that has every week day as an option. When a user picks "Monday" and submits the form I want to echo the date of monday last week. And if he picks tuesday, I want it to give the date of Tuesday last week, on so on. How would I do that? Thank you in advance!
  12. Hi, I'm looking for a code to view the date of the past weekdays. Forexample, if it's thursday, I want it to view the dates for wednesday, tuesday, monday, Friday before. Thank you in advance.
  13. I have one table called statuses(status, dtime, byuser), and one called wallposts(message, byuser, touser, dtime). I want to show statuses and wallposts on my wall, and I want them to sort by date. I need to be able to distinguish between what's a wallpost and what's a status, seeing as wallposts has a byuser. I'd appreciate help on how I'd go about doing this. What I have found so far, is: SELECT * FROM ( SELECT 'Status' AS what, Status AS StatusOrMessage, byuser, 'n/a' AS touser, dtime FROM statuses UNION SELECT 'Message', Message, byuser, touser, dtime FROM Wallposts ORDER BY dtime DESC LIMIT 20 But I'm not quite sure it's right, seeing as I don't quite understand the query. Thank you in advance!
  14. Yeah, it totally makes sense. Thanks for taking the time. Here's what I got: $Wallpostquery = "SELECT byuser, message, dtime FROM wallposts WHERE person='$user'"; $Statusquery = "SELECT status, dtime FROM statuses WHERE byuser='$user'"; $showonwall = array($wallpostquery, $statusquery); I'm a bit rusty on arrays. Like how I'd put it in a while, sort by time and separate them. And will each comment/wallpost keep it's own date posted still? Like I said I'm a bit rusty. Thank you for helping me out.
  15. I apologize for being vague, allow me to try again, I'll use facebook as an example seeing as it's easy to relate to: I have one table which holds status updates(time when posted, by who, message). I also have one that holds wallposts(Time when posted, by who, to who, message). What I want is to have both the status updates and the wallposts to appear on my wall in the chronological order they were posted in. Is this possible?
  16. Hm, could you please give an example what you mean?
  17. Nope. I'm asking for someone who understand what I want, to give me an idea how to more cleverly write it.
  18. So here's what I got: $getwall2 = "SELECT comments.comment, wallposts.message FROM comments, wallposts where comments.byuser='$username' and wallposts.person='$username' ORDER BY dtime DESC LIMIT 0, 10"; $connectgetwall2 = $database->query($getwall2); $wall2 = mysql_fetch_array($connectgetwall2); echo "<table><tr><td>"; echo "<br><h2><img src=\"view.php?user=$user\" width=55 height=40> "; echo "<a href=\"userinfo.php?user=$user\"> $user</a> " .$wall2; echo "</h2></tr></td>"; echo "<tr><td>"; I still can't get it working, I can't figure out how to retrieve from two different tables, put it into one loop and have it seperate comments from wallposts into different tables ordering by when they were posted. If you need an example for what I'm looking for, think of how they have wallposts and status updates posted on your wall on facebook. Help would be highly appreciated!
  19. Hi, I'm trying to write a query that retrieves the comments from one table where "touser=$username" and retrieve statuses from another table where byuser=$username, and I want to sort it all by date posted. How would I go about doing that? I'm used to writing normal single table queries, but retrieving from multiple tables is new to me. Thank you for your help in advance.
  20. On Facebook, when you click on "view friends" on one of your friends' profile, a window pops up. Is that made with PHP? Or is it flash or something? In case it's PHP, what would you use to make something like that? Thank you in advance!
  21. Sorry, wrong code. This one: <?php include("include/session.php"); if (isset($_POST['post1_x']) || isset($_POST['post1_y'])) { $blogtitle = $_POST['title']; $blogintro = $_POST['intro']; $blogpost = $_POST['blogpost']; $username = mysql_real_escape_string($_SESSION['username']); // If no title, exit script. if(!$blogtitle) { echo "Your blog entry needs a title, fool"; exit(); } if(!$blogpost) { echo "You need to actually write something to post a new entry.."; exit(); } $query = "INSERT INTO blogs (title, intro, mainpost, byuser, dtime) VALUES ('$blogtitle','$blogintro','$blogpost', '$username', NOW())"; $result = $database->query($query); mysql_query($result); Header( "Location: selectedblog.php?blog=$username"); } ?>
×
×
  • 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.