Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. this could be the culprit users.fname,, users.service_id // 2 , between fields EDIT :.... I posted this just when you were editing your post.... probably after the select you have something like this $return = mysql_query($query); I will write that line $return = mysql_query($query) or die("Select : " . $query . "<br />" . mysql_error());
  2. you have to adjust it to the rest of your code... what part did not work?.... probably because you cut/paste it without making it coherent with the rest of your code? post your complete code for further help
  3. in that case you should store your results in an array and after that manipulate the array as you wish... per example: $query = "SELECT statez, COUNT(statez) AS Tstate FROM abs GROUP BY statez"; $results = mysql_query($query) or die( "Query Error: " . mysql_error()); $values = array(); // define your array while($line = mysql_fetch_array($results)) { // store each record as an element into the array $values[] = $line; } // here you can display your record in any format that you want echo $values[0]['Tstate'] . " ----- " . $values[0]['statez1'].",,"; echo $values[1]['Tstate'] . " ----- " . $values[1]['statez1'].",,"; echo $values[2]['Tstate'] . " ----- " . $values[2]['statez1'].",,"; echo $values[3]['Tstate'] . " ----- " . $values[3]['statez1'].",,"; echo $values[4]['Tstate'] . " ----- " . $values[4]['statez1'].",,"; echo $values[5]['Tstate'] . " ----- " . $values[5]['statez1'].",,"; ..... echo $values[n]['Tstate'] . " ----- " . $values[n]['statez1'].",,"; // obviously n represent the total number of records /elements in you array .... // no a good solution IMHO... it should be done in a loop mysql_close($link); ?>
  4. comments in your code ^^^
  5. that defeat the purpose of your while loop. the while loop is doing exactly that... echoing a line for each record in your recordset. maybe if you explain a little more your objective I can suggest something different
  6. why are you creating that $resultS variable? .... seems to me that what you want to do is display the records right? it example will do it (very simplified)... notice also how I did assign an alias for your aggregate function to simplify it usage. $query = "SELECT statez, COUNT(statez) AS Tstate FROM abs GROUP BY statez"; $results = mysql_query($query) or die( "Query Error: " . mysql_error()); while($line = mysql_fetch_array($results)) { // here you can display your record in any format that you want probably in a html table echo $line['Tstate'] . " ----- " . $line['statez'] . "<br />"; } mysql_close($link); ?>
  7. if you are using MyIsam storage engine and you have access to INFORMATION_SCHEMA.tables table you can get the last update from there... doesn't work for Innodb storage.
  8. according to MYSQL manual: "It is not permissible to refer to a column alias in a WHERE clause, because the column value might not yet be determined when the WHERE clause is executed. See Section B.5.5.4, “Problems with Column Aliases”." but you can try writing your query in this way: SELECT brands.brand, brands.partid, bullets.bullid, bullets.bullettext, bullets.buorder, count(bullets.partid) as bucnt, bullets.partid as bupartid FROM brands JOIN bullets ON (brands.partid=bullets.partid) WHERE (brands.partid=31537) GROUP BY brand HAVING bucnt > 0 ORDER BY brand, partid
  9. column Update_time in "show table status" maybe?
  10. the first things that I will do: - Review in detail the data model to be sure that it is normalized and do no present design problems. - Review that my model/tables have the appropriated indexes orientated to help my query. - Review and Analyze the selects that I will use to be sure that are efficiently written (having a good data model behind will help). - After complete the 3 previous steps (that will probably solve the majority of the problems) I will explore things like caching, table partitioning or other methodologies to improve performance.
  11. in the code that you were showing (you just changed the code in your post) the variable $id is undefined, that will more likely cause that your query $sql_lowdown = mysql_query("SELECT id, mem_id, the_lowdown, post_time FROM lowdown_db WhHERE mem_id='$id' ORDER BY post_time DESC LIMI 20"); will either fail or not return any value. you must validate that your $id variable effectively has some value and then rewrite that code in this alternative way: $sql_lowdown = mysql_query("SELECT id, mem_id, the_lowdown, post_time FROM lowdown_db WhHERE mem_id='$id' ORDER BY post_time DESC LIMI 20") or die("Query Error: " . mysql_error()); if (mysql_num_rows($sql_lowdown) > 0) { // The query returned values... therefore here you canb continue the rest of your code } else { echo "..No records found.."; };
  12. you are missing a , after itemQty... your select should read mysql_query("SELECT itemQty, SUM(itemQty) AS TitemQty FROM transactions Where itemDescription= 'raffle'") or die (mysql_error()); notice that I also added an alias for the aggregate function... it will allow you to change this line echo $row['sum(itemQty)']; for the more simple echo $row['TitemQty'];
  13. adding to what wildteen88 said.... pay attention to group_concat_max_len (1024 by default)... but can be adjusted if neccesary
  14. now you know how the acronym RTFM was born good post indeed.
  15. without see your tables definition that could lead me to a different suggestion I will say... implement a database TRIGGER over the table "allmessages" ... it could take care of the insert in the other table automatically. a quick google search should lead you to several examples regarding how to implement a Trigger over a table.
  16. I haven't used MATCH too much ... but according to the manual it say : "The search string must be a literal string, not a variable or a column name. There are three types of full-text searches" it maybe the cause of your problem (no tested in my side)
  17. in how many tables of that select you have a field named 'text' ? I will try to write the match line(s) this way match (ads.text, adfields.f_value) against ('%$trimmed%') as relevance
  18. good... glad to help
  19. hummm.. curious... my last select work perfect for me... (be aware that I did post one before this... maybe you are using the incorrect one) $query = mysql_query("SELECT a.clan1, b.clan2 from ".PREFIX."cup_matches a, ".PREFIX."cup_matches b WHERE a.clan2 != b.clan2 AND a.matchno = '1' AND b.matchno = '1' AND b.ladID='b'"); and I used your data a populate the table with several more to be sure that it is working... what you wrote should work too...
  20. did you use this query? $query = mysql_query("SELECT a.clan1, b.clan2 from ".PREFIX."cup_matches a, ".PREFIX."cup_matches b WHERE a.clan2 != b.clan2 AND a.matchno = '1' AND b.matchno = '1' AND b.ladID='b'"); because this one gave me the right results
  21. maybe you can try $query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND LOCATE(' no ', blocked) = 0 ORDER BY hits DESC LIMIT 10 " if the 'no' is always in the middle of the string... wouldn't work if is in the borders. assuming that 'no' will be no part of other part of the string just use LOCATE('no', blocked)
  22. before you try the query of my last post.... are you sure that you have 'b' in the column laid only for those records?... because if not the query is not correct either. it will solve that problem $query = mysql_query("SELECT a.clan1, b.clan2 from ".PREFIX."cup_matches a, ".PREFIX."cup_matches b WHERE a.clan2 != b.clan2 AND a.matchno = '1' AND b.matchno = '1' AND b.ladID='b'");
  23. after you delete the unwanted rows test this query (I did and works fine) $query = mysql_query("SELECT a.clan1, b.clan2 from ".PREFIX."cup_matches a, ".PREFIX."cup_matches b WHERE a.clan2 != b.clan2 AND a.matchno = '1' AND b.ladID='b'");
  24. ok.. don't panic... everything can be fixed. you see how a little piece of information that you miss yo tell could cause that anyone give you wrong alternatives? the first thing that you have to do now is delete all the incorrect rows that the query produced in all of them the common characteristics is that the field matchno should be null (0 or NULL)... if you didn't have ANY rows before with matchno NULL it would clean up the mess. DELETE from PREFIX.cup_matches WHERE matchno IS NULL // replace the proper PREFIX value. try this first... and we can resume to fix your INSERT after you clean the unwanted rows.
  25. how many rows did you have originally in you table with matchno = '$ID' ? remember that the query is making a cross join between all the rows in the table matching the conditions that you defined... if those conditions are incorrect the result is expected.... I suggest you to try just the select (without the INSERT) first and be sure that is is returning the rows/results that you want.
×
×
  • 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.