Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. Adding the condition to the WHERE clause would cause ALL employees to be returned. In the end I just ran a query for each employee and combined them into a single array to use for my line graph. There is not much overhead as generally only a few employees will be selected and I can guarantee my results this way.
  2. That looks correct. Could you let us see your HTML form for the comment as well as the INSERT query? May need the table information from your database as well...
  3. that should work, you want to get it as close to the top of the page as you can, so less code is parsed before it is checked. It would be better if changed slightly: $totalRows_clientes_RS = mysql_num_rows($clientes_RS); if mysql_num_rows($clientes_RS) < 1 { echo "ooooooops"; } would be better as: $totalRows_clientes_RS = mysql_num_rows($clientes_RS); if ($totalRows_clientes_RS < 1 ) { echo "ooooooops"; break; } call the break within the if condition to protect the rest of your code (and to keep things light on the server, no need to parse code that's not going to get used). Also, as you already assign the value of mysql_num_rows() to a variable, it's better to reuse the variable than call the function again.
  4. Running Queries within loops is NEVER a good idea. ESPECIALY if you are planning on passing your app out to general population. multiple people on the same hosting bombarding thier provider with several queries a second just to build a breadcrumb list is really not going to make anyone happy. Add to that the potential for infinate loops and your backing a looser. There are better ways of doing this, as I already said, but you go with what makes you happy.
  5. I'm not getting this, Your server request method is set to get, but you have the following code: ... $opts = array('http' => array( 'method' => 'POST', ... and there is nothing getting passed through the GET global when you move to the next page, even though there are variables in your url......weird
  6. batching it will require that you have a Unique IDentifier column (sorry if that sounds patronising, just covering the bases), then just append "AND UID BETWEEN 1 AND 100000" to the WHERE clause, and bump it up each time. You should be able to get away with 100000 records at a time. you could even write a script to go through it for you using a varible and a multiple of that variable untill the number of rows affected are less than the multiplier (or untill variable * multiplier hits your known table top of 7.something million), but this may need smaller incraments and make sure to close the connection after each batch or else set a persistant connection prior to running any of the batches and close it at the end of them all (should work nicely on a localhost/LAN setup).
  7. you could fling a message out on the page by checking the mysql_num_rows() of your query. obviously there will not be any rows returned if the page has been accessed through error or maliciousness, so if mysql_num_rows($yourQuery) < 1 then show a message.
  8. not sure how deep you can nest IN's, but this should work (in theory): SELECT firstname, lastname FROM users LEFT JOIN partners ON users.id = patrners.user_id WHERE (users.id IN (SELECT frend_id FROM partners WHERE user_id IN (SELECT friend_id FROM partners where user_id = 1))) AND (users.id NOT IN (SELECT friend_id FROM partners WHERE user_id = 1))
  9. no harm, no foul. to select spific columns from your table you simply name them in a comma sepporated list where you are currently using the *. so to show fist name, last name, and user name it could look something like this: SELECT first_name, last_name, user_name FROM my_user_list where my_user_list is the name of the table that you have stored the information in. Also worth noting is that you can select the fields in any order, although your current code will show the fields only in the order that you select them in. so this would output: First Name | Last Name | User Name If you wanted to show it in a different order you can just select the fields in a different order. ps, you should think about looking into my other points as well, perticularly the use of the @ symbol
  10. actualy it is. using SELECT * you are selecting every record in the table. Not only is it more information that you want, thus grossly inefficient, it is also a stupid security risk when the table holds password information. Limit the select statement to only the fields that you need to output and then you will only output the fileds that you want. alternativly - ignore me again, leave your code in a horrible mess, put up another flippant remark and then wait for someone with a little more patience to handle your childishness to come along and tell you how to write bad code.
  11. what do you get if you put this at the top of your token.php page: echo " server method is set to ".$_SERVER['REQUEST_METHOD']; print_r("<br>".$_GET);
  12. Don't use SELECT * for a start. You should also make your mind up whether you want to use print or echo (instread of mixing them both through the code), and deffinately get rid of the @ at the start of your mysql_select_db() line.
  13. eek never had that happen to me. Got this from the MySQL website though:
  14. could you post your actual tables, that query makes no sense to me.
  15. I would guess at a couple of minutes... have never tried a multi-million row update before
  16. Not sure this will work, but it's where I would start: $str_array = explode(",", $unformatedString) for ($i = 1; $i <= array_count($str_array); $i++){ if (isnumeric($i / 4) && $str_array[$i-1] != '\n'){ array_splice($str_array, $i-1, 0, '\n'); $i = 1 } } $unformatedReturn = implode(",", $str_array);
  17. This should work: SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees) , (( SELECT count(employees) FROM info WHERE migrate = 'yes')) AS 'migrate_yes' FROM info WHERE effdate = '$date_search_8' GROUP BY carrier WITH ROLLUP LIMIT 0 , 30
  18. Don't know if this will work but could be worth a try: UPDATE worldcitylist INNER JOIN worldregionlist as country ON (worldcitylist.countrycode=country.countrycode) INNER JOIN worldregionlist as region ON (worldcitylist.region_id = region.region_id) SET worldcitylist.country_id = country.country_id WHERE country.enabled = 1 LIMIT 30 Curious though - if you already have a matching countrycode filed in both tables, what's the point in all this?
  19. Your coming at this from the wrong angle. A much better way to do this is to build a trail as you venture deeper into the nest. It's called a "breadcrumb trail" and is used by most things that operate the way you want your galleries to. It's much more efficient as you only need to run a single query and don't need to loop anything at all. All you need is an array or list and to use a session variable (although you could pass it through the URL it's a bit messy)
  20. while($positions = mysql_fetch_array($selected_positions)) { $position = array(); array_push($position, $positions['car_position']); // 'car position' is the name of the field } you are defining the position array within the while loop. that meens that you are reseting the array each time you iterate through the loop. It's what's causing your problem as it will (best case) only hold the last record parsed by the loop. move the assignment up above the beggining of the loop and you should be fine.
  21. you would want something along the lines of: "SELECT p_alliances.id, p_alliances.name, p_alliances.player_count, p_alliances.rating AVG(p_players.total_people_count) as `average` FROM p_alliances LEFT JOIN p_players ON (p_alliences.id = p_players.allience_id) ORDER BY p_alliances.rating DESC, p_alliances.player_count DESC, p_alliances.id ASC LIMIT %s,%s", array($pageIndex * $pageSize, $pageSize) I doubt it's what you want, but it should give you enough to work with.
  22. It can be done, but we need to know what direction you want the data connection? do you want to show information form the database in the textbox, or have data entered in the textbox added into the database?
  23. Don't quote your table or field names. You are getting quotes mixed up with backticks, they are not the same thing and perform totaly different functions. If you change your error checking to mysql_query($query) or die('Error, query failed : <br /> <br />'.mysql_error()); Then I expect you will get the message 'Unkown Field "Upload".....' Or something else equaly as helpful in identifying the issue.
  24. Try: SELECT sid FROM husbands INNER JOIN wives ON (husbands.sid = wives.sid) INNER JOIN children ON (husbands.sid = wives.sid)
  25. No problem, just an FYI, you can normaly (depends on how your hosting is set up) still use "localhost" for hosted database access as long as the PHP is running on the same server.
×
×
  • 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.