Jump to content

osyrys14

Members
  • Posts

    42
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

osyrys14's Achievements

Member

Member (2/5)

0

Reputation

  1. I start with this... SELECT DISTINCT `column` FROM $db_tb_name Which gives me the list of names. I also need to grab the sum of the column 'usage' for each and display next to each name. Make an array from THE SELECT statement above, and do a while php loop to sum each one possibly?
  2. I'm trying to query a table in the DB that I need to get a list of all the names in the name field, and a total of all of the rows for each name, and then only display the name once, with the total next to it. Is this possible to select, group and sum in one query? I know beginner to intermediate SQL, but this one is a bit above my head, and any assistance would be greatly appreciated. Thanks in advance for any help! Osyrys
  3. That would be great Psycho. How do I go about doing that? Something built into the MySQL server, or something else I need to get?
  4. I've recently tried using this statement, since I found another column in the row that DOES have data that I don't need, so I try this... DELETE FROM cdr WHERE tablename LIKE '%billing_file%'; Still no results, when I know billing_file is in that field, but that's just the start of the name, so I can't use tablename = 'billing_file'
  5. My apologies, I worded that wrong. The rows appear to be empty, but using the SQL commands above do not find or delete them. The text files are aparently filled with something that is showing as blank, but not truly empty. And it's not on an insert statement, they are hourly files we import once a day for querying later for usage statistics. Like an activity log.
  6. I have a DB that I've been working on importing data to from text files. The data imports fine, but if its a report that has no data (or just a header) it inserts what seems to be a blank row. usually, I can delete these with a simple SELECT * FROM table WHERE name=''; to be sure, and DELETE FROM table WHERE name='';, neither of which is returning any results. Also, is there a way to check for this on the import so I won't have the empty rows to deal with in the future. Thanks so much for any help that anyone can provide.
  7. Thank you so much for your help!
  8. I put something in the text box on the search, now it gets this SELECT * FROM cdr WHERE `8` LIKE '%EFM%' AND `6` BETWEEN TIMESTAMP('2012-09-02') AND TIMESTAMP('2012-09-03')It's searching 2 fields, first one ( is an ID code, the other we've been working on is a time/date stamp. Is it possible to make them work together?
  9. I get this as what it's looking for... SELECT * FROM cdr WHERE `8` LIKE '%%' AND `6` BETWEEN TIMESTAMP('2012-09-02') AND TIMESTAMP('2012-09-03')and no search results
  10. It's a dummy database to get the information functional and I have not gotten header names from the client yet so right now, they are all 1, 2, 3, 4, 5, 6, 7, 8, etc. That gets me the correct query string, but since the query is set to just a date format, and the table is date/time, I'm still getting no results. Is there a way to split at the space between the date and time and search that way? The format in the db is 2013-03-29 14:00:00 and the form/search is only 2013-03-29. Thanks so much for the help!
  11. I'm trying to make a search where I pull information out of the column that is date/time (2013-03-29 14:00:00) and have a form search the information by a range provided. I was helped in another thread and I was incorrect in the procedure I need to do, but this is the code I'm using to select * from the db, but what I need to do is display just the ones between the date chosen on the form that submits the query. Any and all help is greatly appreciated! $mydate1 = sprintf('%4d-%02d-%02d', intval($_GET['year']), intval($_GET['month']), intval($_GET['day'])); $mydate2 = sprintf('%4d-%02d-%02d', intval($_GET['year2']), intval($_GET['month2']), intval($_GET['day2'])); $sql = "SELECT * FROM $db_tb_name WHERE `$db_tb_atr_name` LIKE '%$query%' AND `6` > '$mydate1' AND `6` < '$mydate2'";
  12. I now realize I'm doing this whole request wrong. I don't need to compare 2 different date fields, I need that query to show all of the dates between the two put in by the user and compare to the SAME DB column...
  13. Ahhh, that gives me light on it. I appreciate it!!
  14. Here's the whole file, top to bottom... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Search</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <form method="get" action=""> <label>Account ID: </label><input type="text" name="query" /></br> <label>Begin Date:</label> <label>Day:</label> <select name="day"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">18</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <label>Month:</label> <select name="month"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </SELECT> <label>Year:</label> <select name="year"> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> </SELECT></br> <label>End Date</label> <label>Day:</label> <select name="day2"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">18</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <label>Month:</label> <select name="month2"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </SELECT> <label>Year:</label> <select name="year2"> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> </SELECT></br> <input type="submit" name="submit" value="Start Search" /> <input type="reset" value="Reset" </form> <?php if(isset($_GET['submit'])){ $db_host="localhost"; $db_username="myusername"; $db_password="mypasswd"; $db_name="cdrdata"; $db_tb_name="cdr"; $db_tb_atr_space=' '; $db_tb_atr_name="8"; $db_tb_atr_name2="6"; $db_tb_atr_name3="5"; mysql_connect("$db_host","$db_username","$db_password"); mysql_select_db("$db_name"); $query=mysql_real_escape_string($_GET['query']); $mydate1 = sprintf('%4d-%02d-%02d', intval($_GET['year']), intval($_GET['month']), intval($_GET['day'])); $mydate2 = sprintf('%4d-%02d-%02d', intval($_GET['year2']), intval($_GET['month2']), intval($_GET['day2'])); $mydate1 = sprintf('%4d-%02d-%02d', intval($_GET['year']), intval($_GET['month']), intval($_GET['day'])); $mydate2 = sprintf('%4d-%02d-%02d', intval($_GET['year2']), intval($_GET['month2']), intval($_GET['day2'])); $sql = "SELECT * FROM $db_tb_name WHERE `$db_tb_atr_name` LIKE '%$query%' AND `dbdate1` > '$mydate1' AND `dbdate2` < '$mydate2'"; echo $query; $query_for_result=mysql_query($sql); echo "<h2>Search Results</h2><ol>"; echo $query; while($data_fetch=mysql_fetch_assoc($query_for_result)) { echo "<li>"; echo substr($data_fetch[$db_tb_atr_name], 0,160); echo "&nbsp&nbsp"; echo substr($data_fetch[$db_tb_atr_name2], 0,160); echo "&nbsp&nbsp"; echo substr($data_fetch[$db_tb_atr_name3], 0,160); echo "</li><hr/>"; } echo "</ol>"; mysql_close(); } ?> </body> </html>
×
×
  • 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.