Jump to content

pro_se

Members
  • Posts

    131
  • Joined

  • Last visited

Everything posted by pro_se

  1. Try: UPDATE 'pages' SET 'ID_MAIN'='ID_MAIN++' WHERE 'ID_MAIN'='$Update'
  2. like, when I do array_sum($votes_array), i get a small number like 4. its supposed to be counting all the rows in the table..... something is not right with the inserting into an array part of it...
  3. actually, wait..... I have like 30 entries in the table right, and its not making sense because when I do <?php print_r($votes_array); ?> its only printing out one of the rows. I want to get the sum of all the rows, not just one of them...
  4. WOW! Thanks man, that really helped me out! I appreciate it!
  5. <?php $pre_toid = explode("?id=", $_SERVER['HTTP_REFERER']); $toid = $pre_toid[1]; $result = mysql_query("SELECT * FROM `hub` where to_id='".$toid."'"); $nvotes=mysql_num_rows($result); while($row=mysql_fetch_array($result)) { $dbratings = $row["rating"]; $votes_array = array("votes" => $dbratings); } $added_votes = array_sum($votes_array); $divided_votes = $added_votes/$nvotes; $total_rating = $divided_votes; ?> Ok, I got that far, but there is something wrong with the while loop. When I try and print or add the array it only prints or gets the sum of one vote from the array, and I know for a fact that there are at least 30 entries in the table.
  6. So, what I am doing is adding integers from an array (the one I pulled out of the mysql db) together, how can I add the multiple rows I am pulling out... I was thinking of using array_sum, but I did not know how to go about using it..
  7. Well, I can make queries like that shows. What I want to do with inserting the selected table into an array is what I am unsure about.
  8. Hi, I am working on a project where I need to select rows from a table called 'hub' and take the rows where 'to_id' = '$to_id' and put them into an array. How can I get MySql info into an array? Any help is appreciated.
  9. okay, I got the stupid thing to have the if/ else thing work.. now.. all I am getting is the same three friends.. all of them are the same.. how can i display all the friends different? function getfriendsforuid($puid) { $query = "SELECT * FROM `friends` WHERE `passive_id` = '$puid' AND `accpet` = 'y' LIMIT 3"; $result_query = mysql_query($query); $numfriends = mysql_num_rows($result_query); $repeat = 0; while ($repeat < $numfriends) { while($fname1lname = mysql_fetch_assoc($result_query)) { $friend = $fname1lname["acting_id"]; $query = "SELECT * FROM `pics` WHERE `uid` = '$friend' AND `default` = 'y'"; $result_query = mysql_query($query); while($fnam2elname = mysql_fetch_assoc($result_query)) { $pic = $fnam2elname["path"]; $query2 = "SELECT * FROM `user` WHERE `id` = '$friend'"; $result_query2 = mysql_query($query2); while($fnamelname2 = mysql_fetch_assoc($result_query2)) { $uname = $fnamelname2["username"]; $query3 = "SELECT * FROM `pics` WHERE `uid` = '$friend' AND `default` = 'y'"; $numpics = mysql_query($query3); $picsfound = mysql_num_rows($numpics); if ($picsfound >= 1) { echo "<div class=\"friendbar\"><a href=\"/profile/$fnamelname2[username]\"><img border=\"0\" src=\"/u/s_$pic\"></a></div>"; } } } } if ($picsfound == 0) {echo "<div class=\"friendbar\"><a href=\"/profile/$uname\"><img border=\"0\" src=\"/u/s_np.jpg\"></a></div>";} $repeat++; } } and a link to my site is: http://notexting.com/profile/cvarma
  10. well, <?php $file = "something.txt" echo substr($file, 2092); ?>
  11. <?php $string = "String Here... " echo substr($string, 240); ?> Try that out and tell me if it works..
  12. Well, ok.. That Partially works... My database does not have predefined pictures... The pictures are all user uploaded and the path (or filename) is stored into a row on the database. What you gave me works fine when you are looking up images with a specific ID. I need a way to get the path with just the friends user ID. I dont know how to do all that LEFT JOIN and INNER JOIN stuff so I could not modify it to work for me.. Can you explain to me how that works or can you modify the code you sent me to get the path by looking in the 'pics' table where the ID = PUID and get the path out..
  13. Ok, I sent an email to you..
  14. I have made the connection and I have echoed 1 friend. Now what I want to do is echo 3 friends. I was thinking of using a WHILE statement but it did not work when i tried.
  15. Well, I have a 'functions.php' that I include on every page.. Do you want that? I can post it... Its gonna have a lot of irrelevant stuff on it...
  16. Well, the whole thing works, I just need help making the stupid thing display all the rows where the friends id matches whats in the database...
  17. yea, here is the DB Schema -- phpMyAdmin SQL Dump -- version 2.8.2.4 -- http://www.phpmyadmin.net -- -- Host: mysql.cvnetworks.net -- Generation Time: Apr 15, 2007 at 05:54 PM -- Server version: 5.0.24 -- PHP Version: 4.4.4 -- -- Database: `notexting` -- -- -------------------------------------------------------- -- -- Table structure for table `comments` -- CREATE TABLE `comments` ( `commentid` int(12) NOT NULL auto_increment, `toid` int(11) NOT NULL, `fromid` int(11) NOT NULL, `comment` text NOT NULL, `datetime` datetime NOT NULL, PRIMARY KEY (`commentid`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -------------------------------------------------------- -- -- Table structure for table `friends` -- CREATE TABLE `friends` ( `friendshipid` int(12) NOT NULL auto_increment, `acting_id` int(11) NOT NULL, `passive_id` int(11) NOT NULL, `date` date NOT NULL, `accpet` enum('y','n') NOT NULL default 'n', PRIMARY KEY (`friendshipid`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -------------------------------------------------------- -- -- Table structure for table `pics` -- CREATE TABLE `pics` ( `pid` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL, `path` varchar(50) NOT NULL, `default` enum('y','n') NOT NULL default 'n', PRIMARY KEY (`pid`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -------------------------------------------------------- -- -- Table structure for table `profile` -- CREATE TABLE `profile` ( `id` int(11) NOT NULL, `aboutme` text NOT NULL, `im` varchar(50) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `tags` -- CREATE TABLE `tags` ( `tagid` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL, `tag` varchar(20) NOT NULL, PRIMARY KEY (`tagid`) ) ENGINE=MyISAM AUTO_INCREMENT=95 DEFAULT CHARSET=latin1 AUTO_INCREMENT=95 ; -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `id` int(11) NOT NULL auto_increment, `fname` varchar(20) NOT NULL, `lname` varchar(20) NOT NULL, `username` varchar(20) NOT NULL, `password` varchar(32) NOT NULL, `email` varchar(50) NOT NULL, `bday` date NOT NULL, `gender` enum('m','f','o') NOT NULL default 'm', `orientation` enum('s','b','g','o') NOT NULL default 's', `location` varchar(50) NOT NULL default 'Fullerton, CA', `signup_date` date NOT NULL, `ip` varchar(16) NOT NULL, `logintimes` int(10) NOT NULL default '0', `lastlogin` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=69 DEFAULT CHARSET=latin1 AUTO_INCREMENT=69 ;
  18. gahh.. ANYONE? I just tried a couple WHILE loops and they were never ending, they repeated over and over again. I cant figure out where I need the loops placed.
  19. Yes it can be done. Are you looking for someone to do it or are you looking for someone to guide you through it?
  20. pro_se

    preg_replace

    So, what are you trying to do?
  21. Hi, I recently started an endeavor to create a friend system where it will allow people to add people as friends and I have run into quite a bit of trouble, please help. ..I am STUCK! I want to display the friends and their pictures as well as links to their page with their friends on that page. But the design of my page only allows 3 thumbnails to be displayed. I have created the code to display one friend but I cannot get it to display all the friends and limit it to only display 3. Here is the code that I have managed to create: <?php function getfriendsforuid($puid) { $query = "SELECT * FROM `friends` WHERE `passive_id` = '$puid' AND `accpet` = 'y' LIMIT 3"; $result_query = mysql_query($query); while($fnamelname = mysql_fetch_array($result_query)) { $friend = $fnamelname["acting_id"]; $query = "SELECT * FROM `pics` WHERE `uid` = '$friend'"; $result_query = mysql_query($query); while($fnamelname = mysql_fetch_array($result_query)) { $pic = $fnamelname["path"]; } } $query2 = "SELECT * FROM `user` WHERE `id` = '$friend'"; $result_query2 = mysql_query($query2); while($fnamelname2 = mysql_fetch_array($result_query2)) { $uname = $fnamelname2["username"]; } $query3 = "SELECT * FROM `pics` WHERE `uid` = '$friend' AND `default` = 'y'"; $numpics = mysql_query($query3); $picsfound = mysql_num_rows($numpics); if ($picsfound >= 1) { echo "$pic"; echo "\" onclick=\"window.location = '/profile/$uname'\""; } else { echo "npic.jpg\" onclick=\"window.location = '/profile/$uname'\""; } } ?> That only displays one friend.. I was thinking maybe use a while statement to get all the friends but I am not sure of the procedure. Any and all help is welcomed... Oh, and here is the function-call: <?php echo "<div class=\"friendbar\" style=\"cursor:pointer;\"><img border=\"0\" src=\"/u/s_"; getfriendsforuid($puid); echo "></div>"; ?> -- just to put it out there... Thank you..
×
×
  • 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.