Jump to content

Morsusy2k

Members
  • Posts

    66
  • Joined

  • Last visited

Everything posted by Morsusy2k

  1. I managed to make it right. Thanks for the help
  2. Can you help me out with this,I can't seem to find a way to send the data to mysql through ajax/php..:S
  3. Okay so I installed raty to my webs. It works but I can't get it to change the rating in my DB. Take a look: $string = $row['RATE']; $expl = explode(',',$string); $size = count($expl); $rating = 0; $zbir = 0; for ($i=0; $i < $size; $i++) { $zbir = $zbir + $expl[$i]; } $rating = round($zbir/$size,2); echo "<script type='text/javascript'>", "$(function() {"; echo "$('#star').raty({ half: true , score: " . $rating . " , "; echo "starOff: 'source/raty/star-off.png',starOn : 'source/raty/star-on.png',starHalf: 'source/raty/star-half.png',", "click: function(score, evt) {", "alert(score);"; //add code here echo "}", "});", "$('#ocena').html(" . $rating . ");", "});", "</script>"; This works,but this only alerts the selected score,how could I add it to the existing values in my DB? This is what I tried but it does not work. $new = $string.","./* I need variable 'score' here */;$sq9 = "insert into " . $row['ID'] . " (RATE) values ('$new')";$result9 = mysql_query($sql9));
  4. Hehe that was easy,thanks bunch
  5. Well I wanted to make it more dynamic so people could click on eg. 3.15 instead of only 1,2,3,4,5. Something like this http://demos.myjqueryplugins.com/jrating/
  6. Morsusy2k

    Selecting tables

    Okay so I would need to select all tables with prefix 'c' and list their names in php. This is how far i've come: <?php include 'source/connect.php'; $sql3 = "SHOW TABLES FROM mydb LIKE 'c%'"; $result3 = mysql_query($sql3) or die ("Could not access DB: " . mysql_error()); while ($row3 = mysql_fetch_assoc($result2)) { echo $row3; //echoes nothing,how could I echo the table name? }?> Also I would like if that could be done for only first 10 tables. (Only 10 tables select).
  7. Okay so I am trying to make a star rating system on my website,but I am having problems with JS. The problem is that I can't get the coordinates of the mouse INSIDE the div,I can only get screen coordinates. :S This is my code: <div id='stars'><div id='stars1'></div></div><div id='mark'>0</div> $(document).ready(function(){ $(function(){ $("#stars").mouseenter(function(){ $("#stars1").show(); $(document).bind('mousemove', function(e){ //1 //var parentOffset = $(this).parent().offset(); //var x = e.pageX - parentOffset.left; //2 var center = (window.screen.width - 1122)/2+283; var x = e.pageX - center; $('#stars1').css('width',x); }); }); $("#stars").mouseleave(function(){ $("#stars1").hide(); }); });}); I found a solution online but it is not working,that is why its commented out,the error is: Uncaught TypeError: Cannot read property 'left' of undefined and I get this error every time I move the cursor. And in the other example (2) I tried to calculate the distance from the left border of the browser,but this one works only for me..Since I have used percentage (%) instead of solid units (pixels) its kinda hard to achieve.. I hope you understand what is the problem. Thanks.
  8. It seems like it works now,I knew its something simple,so no quotes in table names anymore. Thanks Ingolme
  9. Okay I got a headache because of this So basically I am trying to get if table exists in my DB,if yes echo '1'; and if not echo '0'; This one keeps loading forever: <?php include 'connect.php'; $mytable = 'c27'; $table ='select * from c27'; //$table ='show tables'; while ($row = mysql_query($table)) { if ($row == $mytable) { echo "1"; } else { echo '0'; } }?> This fails too: $sql2 = "select * from 'c27'";echo $sql2."<br/>";$result2 = mysql_query($sql2);echo $result2."<br/>";//this is line 84while ($row2 = mysql_fetch_assoc($result2)){echo '1';} if (!$result2) {echo "0";} else {echo "1";} In this test first loop (while) gives this error: select * from 'c27'Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in ......./page.php on line 85 As you can see echoing result outputs nothing... And in the second loop (if) it always ends up with echoing 0. 'c27' table really exists in my DB and I can detect it in SQL query box but not in php.. F1,thanks
  10. I suppose I don't need arrays anymore. Seems like its not working again :S for(i = 1; i <= 10; i++) { $("#pictures" + i).click(function(){ alert(i); //this alert always outputs '11' :S $("#roll" + i).show(); });}
  11. I thought it would be simple. But there is something wrong again,look: var pictures = [ "#picture1", "#picture2", "#picture3", "#picture4", "#picture5", "#picture6", "#picture7", "#picture8", "#picture9", "#picture10" ];var info = [ "#roll1", "#roll2", "#roll3", "#roll4", "#roll5", "#roll6", "#roll7", "#roll8", "#roll9", "#roll10" ]; alert(pictures[1]); alert(info[1]); //these alerts works for(i = 0; i < pictures.length; i++) { $(pictures[i]).click(function(){ alert(pictures[i]); alert(info[i]); //these dont :S //output is 'undefined' $(info[i]).show(); }); }
  12. I have 10 divs with pictures,named picture1,picture2,...,picture10. And I have 10 divs with info on these pictures,named info1,info2,..,info10. Is it possible to do something like this: var pictures = [ "#picture1,..,#picture10];var info = ["#info1",...,"#info10"];jQuery.each(pictures, function() { $(pictures).click(function(){//info with same index$(info).fadeIn(200); });}); Instead of doing this 10 times: $("#picture1").click(function(){ $('#info1').fadeIn(200);}); I hope you understand what I meant to say Thanks.
  13. Morsusy2k

    Thumbnail

    Hi, I am having trouble with creating thumbnails of the pictures uploaded on my website. This script on the first sight works perfectly but when I opened some of the files,some were ok but some lost too much of their color and become almost white,some almost black,others lost quality (on some you can't even say what is on them)..etc.. function thumbnail($image_path,$thumb_path,$image_name,$thumb_width) { $src_img = imagecreatefromjpeg("$image_path/$image_name"); $origw=imagesx($src_img); $origh=imagesy($src_img); $new_w = $thumb_width; $diff=$origw/$new_w; $new_h=$new_w; $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); imagejpeg($dst_img, "$thumb_path/$image_name"); RETURN TRUE; } Is there any way to do this in function like this but better working? Thanks.
  14. Thanks for the tip I made it work
  15. Okay so I have 10 images in one div in a row (with overflow:hidden). I would like to make them move to the left so the others can show up. I added two div-buttons and my code looks like this: $(document).ready(function(){ $(function(){ //next button $('#napred').click(function(){ //div holding the images $('#nove').animate({left: "-=500"}, 200); }); //back button $('#nazad').click(function(){ $('#nove').animate({left: "+=500"}, 200); }); });}); And this works what its supposed to do, BUT there is one problem and that is that you can keep scrolling the images till infinity. I would like to add restrictions eg. if #nove left property is higher than 15px you are able to click next but not back button, and if less than -1350 you could click on back button but not on the next. This is what I came up to but it fails to work: $(document).ready(function(){ $(function(){ var b = 15; var c = -1350; $('#napred').click(function(){ var a = $("#nove").css('left'); if (a < { $('#nove').animate({left: "-=500"}, 200); } }); $('#nazad').click(function(){ var a = $("#nove").css('left'); if (a) > c){ $('#nove').animate({left: "+=500"}, 200); } }); });}); I would appreciate if someone could help me solve this problem and I can bet that solution is simple :DThanks
  16. I know it can be done i just don't know where to start..I'm using simple php linking system,for now.
  17. But how can i do that when i include a menu in other pages?I would need a script to strip a url and switch only the matching menu item to active.
  18. Well jQuery does all the stuff. Class ".active" is not set in php but in jQuery. And jQuery resets after reloading(when clicking a link) and it sticks .active to home button. I can't find the solution on this site but it works on that site.I found some useful links but i still cant seem to get it right :S
  19. Okay so I added a jQuery lavalamp menu and I installed it in my header.php witch i include in my pages.The problem is when i click a link from the menu. It gets on clicked page but the "home" button keeps class="active" to itself.So the problem is that after loading a page menu resets and wont keep active button actually active.And i can't change class inside php cause its included and it will be same on all pages.I hope you understand and i hope you have an answer. :)Thanks.
  20. Morsusy2k

    php if mysql

    Oh,i just found what was the problem,i included that orange1.css inside header.php witch i included on the page :SStupid mistake.It works now,thank you very much
  21. Morsusy2k

    php if mysql

    It still loads orange1.css as i can see from page source: <link rel="stylesheet" type="text/css" href="orange1.css"> And i added an echo $css; in the script so i can see witch one actually is and it says orange2...:S Yeah i know,i am just testing the script,i will fix that later,if i have any problems with that i will post here
  22. Morsusy2k

    php if mysql

    Okay so I'm trying to create a page where php will load a css file from mysql.To make it simple: A user that registers on the page specifies its favorite color in the registration. And i need a php to use only that css file. Here is my test code: So there are two css files 'orange1' and 'orange2'. <?php $con = mysql_connect("localhost","root","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_test", $con); $result = mysql_query("SELECT * FROM users"); if($row = mysql_fetch_array($result)) { echo $row['favcol']; } mysql_close($con);?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Test</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><?phpif($row['favcol'] == 'orange1') { echo "<link rel='stylesheet' type='text/css' href='orange1.css'>";} else {if($row['favcol'] == 'orange2') { echo "<link rel='stylesheet' type='text/css' href='orange2.css'>";}}?></head><body><?php include("header.php"); ?><div id="content">TEXT TEXT TEXT</div></body></html> This code only loads orange1.css in any case... Will that slow down mu site?And is there any better solution for this? (and by 'better' i mean simpler) Thanks.
  23. Well wouldn't that do the same thing my code did? It would loop until infinity and i wouldn't be able to add any more code.
  24. What do you mean by that?How would you do this?
×
×
  • Create New...