Jump to content

mikwit

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mikwit's Achievements

Member

Member (2/5)

0

Reputation

  1. Solved the problem, had to do with 404 redirecting and / missing from vote.php in the url part of the ajax code
  2. Thanks for your help, I have this javascript/php solution using ajax that works on some pages and not on others. The general Idea: There is a link within a <span> that when clicked, fades out and fades back in with an updated message. This message changes based on an id tag found in the link. On some pages the id tag works fine, on others it fails. No clue why. Here is the java script that feeds the php Update: I have found that this occurs only on page that are redirected using mod_rewrite, any ideas? $(function(){ $("a.vote_up").click(function(){ //get the id the_id = $(this).attr('id'); $("span#votes_count"+the_id).fadeOut("fast"); $.ajax({ type: "POST", data: "action=vote_up&id="+the_id, url: "votes.php", success: function(msg) { $("span#votes_count"+the_id).html(msg); //fadein the vote count $("span#votes_count"+the_id).fadeIn("fast"); } }); }); }); The php votes.php which is called is $number = $_POST['id']; $action = $_POST['action']; if($action=='vote_up') //voting up { $q = "UPDATE main SET likes = likes + 1 WHERE number = $number"; setCookieVote($number); } $r = mysql_query($q); if($r){ $votes = getAllVotes($number); echo $votes[0]; } elseif(!$r) //voting failed { echo "Failed!"; } ?> Sometimes the id gets passed through and number is the id in the link, other times the number is blank. This works: <span class="votes" id="votes_count112"><a href="javascript:;" class="vote_up" id="112">1</a> </span> While on another page with the same libraries loaded <span class="votes" id="votes_count113"><a href="javascript:;" class="vote_up" id="113">1</a> </span> does not work and returns "Failed!". I know it's a little messy, I'm not too great and the project is pretty loose. Thanks a lot.
  3. Sorry, I figured it out myself, I had both a missing ) and an extra " which was throwing me off...
  4. So I know this should be an easy fix, but I've tried every thing I can think of and still nothing will get this error to go away. I looked for escaped quotations, but I couldn't find any, and I use textwrangler to do editing so it would have been more visible if that was the problem. Also I'm new to the whole javascript thing, but have a decent background in php. Here's the code. I'm getting the error in firebug "missing ) after argument list });\n" Just as a note I'm using jquery with flot. $(function () { var options = { lines: { show: true } , xaxis: { min: 0 } }; var data1 = []; var placeholder = $("#placeholder"); var show1= 0; $.plot(placeholder, data1, options); // fetch one series, adding to what we got var alreadyFetched = {}; $("input.fetchSeries1").click(function () { data1= []; if (show1 == 0) { show1 = 1; } else { show1 = 0; } plot(show1); } }); //Error is here function plot(show1){ var weight = document.getElementById("weight").value ; var dataurl = "http://drink.mikwit.com/test3_data.php" + "?w="+ weight"; if (show1 == 1) { var dataurl = dataurl + "&opt1=1"; } // then fetch the data with jQuery function onDataReceived(series) { // extract the first coordinate pair so you can see that // data is now an ordinary Javascript object data1.push(series); } // and plot all we got $.ajax({ url: dataurl, method: 'GET', dataType: 'json', success: onDataReceived }); $.plot(placeholder, data1, options); }
  5. So I've gotten it to work sort of SELECT `number` , `school` , `date` , `text` , `category` , `likes` , `dislikes` , `md5` , `banned` , b.CommentCount , `name` , `title`, m.last_date FROM main a LEFT OUTER JOIN ( SELECT replyto, COUNT( `text` ) AS CommentCount FROM `comments` GROUP BY reply_to ) b ON `number` = b.reply_to left outer JOIN ( select reply_to, max(`date`) AS last_date from `comments` GROUP BY reply_to) m on `number` = m.reply_to NATURAL JOIN college_list WHERE school = 21 ORDER BY last_date This works, but I get null fields and it messes with the sorting... I've tried a max(ifnull(`date`,[date from post] )) but I don't know how to call the date of the post. So is there there a way to do Order by maximum(last_date,date) ??
  6. I don't get what you mean, I would think you have to merge in the date of the most recent comment of that post and then sort by that
  7. okay so I have two tables, one table has the topics, while the other has all the comments for all the topics. main comments ________________ __________________ |number|text|date| |reply to|time|date| |______|____|____| |__________________| Currently, when I query for topics, I get number, text, time + count of comments whose replyto = number through this query. SELECT `number` , `date` , `text`, b.CommentCount FROM main a LEFT OUTER JOIN ( SELECT replyto, COUNT( `text` ) AS CommentCount FROM `comments` GROUP BY replyto )b ON `number` = b.replyto ORDER BY `date` DESC LIMIT '.$lowlim.', 15 Instead of ORDER BY date (of the post), I would like to figure out/find a way to order by most recent date of comment. Any help or guidance would be greatly appreciated
  8. I figured out a way to do it in sql using natural join, sorry for the un needed post
  9. Hi, sorry I'm pretty rusty on this so there is probably a simple answer in the manual I just can't seem to find it. So I have a very basic table in mysql set up with 1 column for reference number and one for the title. Is there a way to load this table into an array so that anytime I want to convert a reference number into it's corresponding title I don't need to do a new query? I want to keep the queries down to a reasonable level. Thanks ahead.
×
×
  • 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.