Jump to content

radar

Members
  • Posts

    645
  • Joined

  • Last visited

Everything posted by radar

  1. radar

    join issues..

    I figured the error out, it was where i had the WHERE clause, it needed to be right after left join i guess. I also figured out the mathmatics for figuring out one of the math problems... Now through the SQL query line, does anyone know how to figure out percentage? specifically what percent of d.reg_price is d.sale_price in php i do it like this: $count1 = $num_amount / $num_total; $count2 = $count1 * 100; $count = number_format($count2, 0); return $count; so would i do something like d.sale_price / d.reg_price * 100 and call it good? I tried that, and if it's an even % like 50% it works well. Otherwise, it doesnt really work at all.
  2. radar

    join issues..

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN orders AS o ON o.d_id = d.id GROUP BY o.d_id, d.id ORDER BY d.start_da' at line 6 phpmyadmin code breakdown SELECT d.id, d.d_id, d.reg_price, d.sale_price, d.title, d.img, d.img_cnt, d.start_date, d.end_date, d.min_qty, d.max_qty, d.txtAbout, d.status, SUM( o.d_id ) AS orders_cnt FROM deals AS d WHERE d.start_date <= '2010-08-09' AND d.end_date >= '2010-08-02' AND d.status =1 LEFT JOIN orders AS o ON o.d_id = d.id GROUP BY o.d_id, d.id ORDER BY d.start_date LIMIT 0 , 30
  3. radar

    join issues..

    [/code] $sql = "SELECT d.id, d.d_id, d.reg_price, d.sale_price, d.title, d.img, d.img_cnt, d.start_date, d.end_date, d.min_qty, d.max_qty, d.aboutTxt SUM(o.id) AS orders_cnt, FROM deals AS d WHERE start_date <= '".$now."' AND end_date >= '".$end_time."' AND status=1 LEFT JOIN orders AS o ON o.d_id = d.id GROUP BY o.d_id d.id ORDER BY d.start_date"; [/code] when I echo this out, it comes up with: SELECT d.id, d.d_id, d.reg_price, d.sale_price, d.title, d.img, d.img_cnt, d.start_date, d.end_date, d.min_qty, d.max_qty, d.aboutTxt, SUM(o.d_id) AS orders_cnt FROM deals AS d WHERE d.start_date <= '2010-08-09' AND d.end_date >= '2010-08-02'AND status=1 LEFT JOIN orders AS o ON o.d_id = d.id GROUP BY o.d_id d.id ORDER BY d.start_date and when i run that through phpMyadmin it gives me a syntax error, i magine with the WHERE clause. on top of this error, is there any way to find out percentages in the query? ie what % is d.sale_price of d.reg_price and is it possible to do math involved too such as MATH(d.max_qty - orders_cnt) as remaining or something like that?
  4. have you done: echo "<pre>"; print_r($row); echo "</pre>"; to check the contents of $row?
  5. yeah where the comment is, thats where the page code belongs.
  6. that is so that you can pass the language to the php script to verify.. but then once you set the cookie you would do a redirect like this // in english page if($_COOKIE['TestCookie'] == 'Serbian') { header("location:serbian/index.php"); } else { // english page here } in serbian page: if($_COOKIE['TestCookie'] == 'English') { header('location: ../index.php'); } else { // serbian page here } simple as that.. then of course, as you pass the variable off the images ?lang=english or ?lang=serbian you would need to do this in both pages as well $_lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : ''; setcookie("TestCookie", $_lang, time()+60*60*24*365); /* expire in year */ if($_lang == 'English') { // redirect to english page } or in English page $_lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : ''; setcookie("TestCookie", $_lang, time()+60*60*24*365); /* expire in year */ if($_lang == 'Serbian') { // redirect to serbian page }
  7. Yeah what I would do, is on your index.php or whatever... is write the cookie using PHP $_COOKIE will do that for you... but basically you would do something like <a href="index.php?lang=english"><img src='' border='0' /></a> <a href="index.php?lang=serbian"><img src='' border='0' /></a> then in php do: $_lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : ''; setcookie("TestCookie", $_lang, time()+60*60*24*365); /* expire in year */
  8. I got it figured out I guesss... Still don't know why my trim wasnt working... but basically my var responseTextTrim = trim(originalRequest.responseText); was failing, causing the responseTextTrim to be esentially nothing (so bad that not even an alert comes up for it).. so i change the next line to $('TransMsgDisplay').innerHTML = originalRequest.responseText; and it works correctly. so guess that's what i'm doing.
  9. Alright working on a site, getting my navigation working.... only thing is it doesn't work... function changeNav(url) { var myRand = parseInt(Math.random()*99999999); var srcs = url+'&ints='+myRand; $('TransMsgDisplay').innerHTML = '<p><img src="templates/site/images/indicator.gif" align="center"></br>Loading Page, Please Wait.</p>'; var myAjax = new Ajax.Request( srcs, { method: 'get', onComplete: processNav }); } function processNav(originalRequest) { var responseTextTrim=trim(originalRequest.responseText); $('TransMsgDisplay').innerHTML=responseTextTrim; } that is my ajax-cs.js file. then my php: case about: ########### BEGINNING OF ABOUT PAGE ############ $sql = "SELECT aboutTxt FROM about"; $data = mysql_result(mysql_query($sql), 0); $ybd->assign('data', $data); $page = 'flat_text.tpl'; break; ################ END OF ABOUT PAGE ################## if ($page != "") { $content = $ybd->fetch($ybd->$template_dir.'site/'.$page); if ($_int == '') { $ybd->assign('content', $content); } else { echo $content; return $content; } } then my html to call the link... <a href="index.php?pg=about" class="nav_links" onmouseover="bgchange('nav4');" onmouseout="bghide('nav4');" onclick="changeNav('index.php?pg=about'); return false;">About Us</a> the first part of the ajax works (in that it changes to my indicator.gif image. but it just gets stuck there.. dont see any errors myself.. when i throw an alert into the processNav i just get an alert of: [object Object] which ive never gotten before.
  10. either that, or they do a position: relative; top: 50%; background-repeat: no-repeat; something like that might be more logical depending on the image.. again its all css.
  11. that is javascript... to create a cookie... and then you can use php to read that cookie... for an image to create a cookie, that's how you'll have to do it.. or rethink it, if someone is clicking on an image, its either doing something already or going somewhere.. perhaps once they get to where they're going is when PHP should set the cookie.
  12. I dont know i havent run it... im actually working on a different part of the site atm.. this part is just an afterthought of the uploading feature in the administration panel. so figured i would figure out how to do it, and save that info to add it in next week.
  13. Okay so based on that code, i would change mine effectively to something like... $prod_img = "../uploads/".$folder."/".$image_name; $srcimg = ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); // does this work for .bmp, .gif, .jpg, .png as well? because i'm allowing the use of all of those through this script. $width = '432'; $sizes = getimagesize($_FILES["filefieldname"]); $aspect_ratio = $sizes[1]/$sizes[0]; $new_height = abs($width/$aspect_ratio); createImage($width, $new_height, $srcimg, $prod_img_thumb[$cur_img]);
  14. thats actually css to make it stay in place, but it is background-repeat: no-repeat;
  15. what exactly is it doing? a demo? some code? something at least....
  16. its a godaddy hosting service issue, godaddy is great to register your domain but isnt used for hosting by anyone serious.
  17. why not just do a search on the entire site for maxHeight and remove them all.. that'll get you the desired effect that you want. you answered your own question.
  18. function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } createCookie('ppkcookie','testcookie',7) var x = readCookie('ppkcookie1') if (x) { [do something with x] } eraseCookie('ppkcookie')
  19. Problem was, it was bringing the style.display as being blank, so i had to add in an else if statement to account for that first click.
  20. Okay So i have a div that I need shows up hidden initially via CSS display: none So I wrote this function to toggle the display of that div and it's contents.. function toggleDisplay(e){ element = document.getElementById(e).style; if (element.display == 'none') { element.display = 'block'; } else { element.display = 'none'; } } problem is, in both IE8 and FF I have to click the button twice in order to get it to change the style the first time (from hidden to block)... any ideas?
  21. Just checking in, anyone know how to do this today? I posted the entire code, though really the only part that will matter is: $image_name = $_FILES["filefieldname"]["name"]; $newname = "../uploads/".$folder."/".$image_name; move_uploaded_file($_FILES["filefieldname"]["tmp_name"], $newname); how to change that so that it changes the width to a certain number, and will auto adjust the height to the neighboring height ('constrain proportions'). I've never had to do it, don't know how. and yeah. If i can get the code for doing it one time, i should be able to theoretically copy the same code to do it a 2nd time?
  22. Greetings.. I have an ajax application i'm creating, that allows uploading images 1 at a time. That part works, and it works well. What I need to know now, is how would I go about converting the existing code I have, to change the sizing of it twice as well as renaming the images to something more website friendly. here is the code that i currently have, im sure this is easy but as i can't find any workable code on the google, i am lost as to how to modify it. so any help is appreciated. <script language="JavaScript" type="text/javascript"> if(!/(\.bmp|\.gif|\.jpg|\.jpeg)$/i.test(window.parent.document.form1.filefieldname.value)) { window.parent.document.form1.filefieldname.value = ""; } else { <?php function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } $folder = isset($_POST['folder']) ? $_POST['folder'] : ''; if($folder == '') { $rand = rand(5, 1000000); $folder = 'temp'.$rand; ?> window.parent.document.form1.folder.value = "<?php echo $folder; ?>"; <?php } if(!is_dir("../uploads/".$folder)) { mkdir('../uploads/'.$folder); } else { $rand = rand(5, 100000); $folder = $folder.''.$rand; mkdir('../uploads/'.$folder); } $image_name = $_FILES["filefieldname"]["name"]; $newname = "../uploads/".$folder."/".$image_name; move_uploaded_file($_FILES["filefieldname"]["tmp_name"], $newname); ?> var parDoc = window.parent.document; var A = window.parent.document.form1.upload_cnt.value; A = Number(A); B = 1; var cnt = A + B; if(cnt == '8') { window.parent.document.form1.filefieldname.disabled=true; } parDoc.getElementById('upload_cnt').value = cnt; parDoc.getElementById('files_list').innerHTML += '<br><a href="../uploads/<?php echo $folder.'/'.$_FILES['filefieldname']['name'] ?>"><?php echo $_FILES['filefieldname']['name'] ?></a>'; window.parent.document.form1.filefieldname.value=""; } </script>
  23. Okay I have a design i'm working on, and im attempting to use div's/css for all the layout and styling options. My problem is i have never used div's before so i don't quite grasp the concept of their nesting, and the css formatting... Yesterday I had 3 divs.. a main div with an absolute position, and 2 inner div's with a relative position. while my CSS made everything display correctly -- i had a blank space at the bottom of the screen about 4 inches high (as tall as one of the images)... I finally gave up on that and made that second div part of the background image and got rid of it all together. So with the image attached, can anyone give me a sample of how i would design that using div's with some basic css? I can and will slice the image up however I need to.. the grey center part would need to auto expand with the body.... and i'll also be adding another grey box (without any images), right below this one. any help is appreciated because i'm freaking lost... the imagemainbox.jpg is the main box i need to format -- the other image is the entire 'body' how it looks. the little dollar sign icons on the left, and the bubble on the right are both part of the background image of the page with an absolute position. the main box, the lower box, and the secondary box on the right i'm unsure how to get setup right. so if anyone can help me understand, i would appreciate it. [attachment deleted by admin]
  24. $pagenum is wrong in that generally you want to get the index of the very last item queried. or count of it rather. on page 1 you are looking for all of them with a limit of 10, on page 2 you are looking for all of them from the 2nd entry down to the 11th and so on.
  25. here is a sample of a left join that i use with a where clause, and other stuff too. $sql = "SELECT SQL_CALC_FOUND_ROWS cust.id, cust.f_name, cust.l_name, cust.email, cust.password, cust.optin, cust.status, o.c_id, d.d_id, COUNT( o.id ) AS orders_cnt, COUNT( d.id ) AS deals_cnt FROM customers AS cust LEFT JOIN orders AS o ON o.c_id = cust.id LEFT JOIN deals AS d ON d.d_id = cust.id WHERE cust.l_name LIKE '".$_pid."%' GROUP BY o.c_id, d.d_id ORDER BY cust.l_name LIMIT ".Paginate::getCurrentIndex().", ".Paginate::getLimit();
×
×
  • 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.