Jump to content

Maximus

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Maximus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Maybe this will clear it up a bit. As you can see, I'm performing a sepperate query each time the loop iterates...other times its just a simple SELECT from one table and get an ID and use that to SELECT various things from another table. So would JOIN be more appropriate for these things, or does it not really matter? $query = mysql_query("SELECT `id`,`stockid`,`quantity` FROM `user_stocks` WHERE `userid`='$_COOKIE[userid]'"); while($g = mysql_fetch_array($query)) { $info = mysql_fetch_array(mysql_query("SELECT `name`,`tag`,`value` FROM `stocks` WHERE `id`='$g[stockid]' LIMIT 1")); //echo various info here }
  2. I've only recently begun looking at mysql optimization and performance, and something that I can't find answered anywhere: is a join/left-join/inner-join better than using multiple SELECT queries to extract information from 2-3 tables? Especially since I often use multiple queries in conjunction with a while loop in PHP to retrieve info, so there are a lot of select queries happening. And by "better" I am of course talking about performance. Any help is appreciated!
  3. it isen't. Maybe its the server configuration. Oh well, it'll do, thanks!
  4. Aha, that works! However, it also adds "&1173764234422" to the end of each url, which I belive is the unix timestamp. I guess I could remove that, but lets see if there is a better method.
  5. I am trying to get the current page's filename, it can be gotten with "$_SERVER['PHP_SELF']". However that only tells you the filename (test.php) and not the actual variables added onto it (test.php?page=3). Can someone help me?
  6. You're right, it is a varchar field. I changed it (in table structure) to "INT" and now it works perfectly. Thanks so much!
  7. Hi, I am trying to retrieve 10 entries with the highest value in field "votes". $result = mysql_query("SELECT * FROM `sites` ORDER BY `votes` ASC LIMIT 0,10"); while($g = mysql_fetch_array($result)) { echo '<br>'.$g['name'].' - '.$g['votes'].' Votes</a>'; } The code above displays ten entries, but doesn't but them in order from high to low. I don't understand... The output looks like this: dsgdsg - 0 Votes dgds - 0 Votes omg lol - 0 Votes gkjkfgs - 0 Votes fhfd - 0 Votes lhhgllk - 0 Votes dfhjdfj - 2434 Votes test - 5 Votes gjdfd - 5765 Votes fjdgdd- 64 Votes Ignore the phony names, but rather focus on the order of the "votes"...its really weird.
  8. I am currently doing a lot of work with AJAX based web applications, and I find it to be a real drag that you cannot use the "onLoad" event to call functions when loading sections of a page with AJAX. My problem is that I have to execute a piece of code as soon as the page is loaded (dynamically, using ajax). On normal sites, this would work with the onLoad property, so once the page has loaded, that event would trigger a JS function of my choice. But with AJAX, only a part of the site "refreshes/loads" so this event handler is useless. I have tried simply putting the function I want to execute upon loading in script tags like so: <script type="text/javascript"> loadContent('pagename', 'divname'); </script> but with no success :-( Does anyone know how to solve this problem? This is really important to me, and I would really appreciate any help, thanks.
  9. Yes, I checked via phpinfo, everything related to GD is enabled.
  10. Hi, I am trying to create an image via php.  I get "the image cannot be displayed, because it contains errors" message when viewing it. I don't know what I've done wrong, can someone point it out to me?  Thanks! [code]<?php header("Content-type: image/png"); $string = $_GET['text']; $image = imagecreatefrompng("images/image_price.jpg"); $color = imagecolorallocate($image, 255, 255, 250); $font = "images/font.ttf"; imagestring($image, $font, 0, 0, $string, $color); imagepng($image); imagedestroy($image); ?> [/code]
  11. I think I have it figured out now, thanks a lot Nicklas :P Also thanks to Orio for putting in the effort, thanks guys!
  12. I tried your method Nicklas, but it puts it all into one big string when printed. I need it seperate...age into $age, hobby into $hobby etc. I also tried Orio's code, and while I found that to work, it has the same problem, I need each "answer" (text behind the -) to be put into a seperate variable that I can use later on. Thanks.
  13. Hi, I have been trying to parse a text file and then retrieve information from it.  Sadly though, I have tried various methods and gotten nothing to work the way I wanted it to work.  I want to parse a .txt file and then retrieve 3 things from it: "name", "age", "hobby" and store each in its own variable..  My text file looks like this: [code]name - nancy smith age - 24 hobby - painting, playing computer games, reading and horse-back riding!! [/code] So basically the code needs to search for (example) "name" and parse until it finds the "enter" to the next line, at which point it stops and goes to "age". I don't know if this makes sense, but all I want it to do it retrieve each attribute and put it into a variable.  If someone could help me, that would be great!
×
×
  • 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.