Jump to content

Rohlan

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Everything posted by Rohlan

  1. And with this said I conclude that I did not know what was going on in the background Thanks, that worked! Even if I now have an extra query per item... hehe.. I'll live.
  2. I am changing the values through phpMyAdmin, forgot to mention, that is where $row["my_field"] comes from Thanks!
  3. Hi! Right now all I'm doing is running a couple of tests to decide if what I'm trying to do can be done this way: I have a while loop doing this: while($row_email = mysql_fetch_array($result)) { echo $row["my_field"].","; sleep(10); } This is echoing: "0,0,0," because there are 3 rows in my table and all of them have a value of "0". I put the sleep(10) there because I want to be able to change the value of one of the fields while the script is "asleep", so that it echoes that value out the next time it loops. So if I were to change the value of "my_field" to "1" after 1~10 seconds, it would echo "0,1,1," or something similar. Basically what I want is to change the values that will be echoed after the script is done processing while the script is running. Right now, theoretically, what I have should be enough right? am I missing something? Is this simply impossible? does sleep() not work the way I'm seeing? Thanks!
  4. I understand and that is what I will be doing. Right now though, I need a speedy edit to one of my scripts and it'd take too long to do it right now that I'm running short on time. Thank you for helping me!
  5. Hi everyone. I just formatted my PC and got my server running and I need to re-configure it like it was before. The one thing I'm forgetting is how to enable PHP to recognize the "<? ?>" tags. Right now I can't remember what that's called on the php.ini file and thus my scripts are failing to run and PHP's just throwing a fit at me Anyone able to refresh my memory? Thanks!
  6. I figured it out. I had an extra query that I used to obtain "$row['lista_emails']", I placed that query inside the while loop and it started working properly, obviously that variable needs to be updated each time the loop restarts, but this wasnt happening before because it was outside the loop. Thanks for the time.
  7. There are 5 rows in that table. The code generates this output when I run it: And the query that's supposed to loop will run, but only once, and if I run the script again, it works again but for the next row only... it seems to only run once and only once even though its supposed to be looping..
  8. Here's the code: <?php include("config.php"); include("opendb.php"); $sql="SELECT lista_emails FROM noticias WHERE id=1"; $result=mysql_query($sql); $row = mysql_fetch_array($result); echo $row['lista_emails']; echo "<hr>"; $sql2= "SELECT * FROM subscritores"; $result2=mysql_query($sql2); while($row2 = mysql_fetch_array($result2)) { $counter = $counter + 1; $lista = $row['lista_emails']; $email = $row2['email']; $pos = strpos($lista, $email); echo $counter; if ($pos === false) { echo "Enviar para '$email' "; mysql_query("UPDATE noticias SET lista_emails='".$row['lista_emails']."$email;' WHERE id=1"); } else { echo "Não enviar para '$email' "; } echo "<br>"; } include("closedb.php"); ?> The problem is the query inside my while loop... it seems to only happen once during the whole loop..
  9. Thanks Silverado_NL, that fixed it Thanks for you too The Little Guy, however this is just an internal script I need to run locally.
  10. Hi. This is my code, it queries the database to try and find the speficied email on my mysql table. $sql2="SELECT * FROM noticias WHERE id='1' AND lista_emails LIKE %".$rows['email']."%"; I get an error, saying: I guess I need to escape the @ symbol, how do I do this?
  11. Thanks to Russel, I've got it working. He pretty much handed me the code and I gladly accepted it and its running perfectly, hurray! Thanks Russel Happy New Year to everyone ~
  12. Thanks again. I can't get it to work, RusselReal. Lots of Javascript errors popup on firefox. I'm not too experienced with javascript so can't really tell what's going on..
  13. I've searched a lot for a proper solution using javascript/ajax but have come up empty as most of them are really just doing a "virtual" pagination... instead of querying each page, they query all the results then simply proceed to paginated those contents. Though I'm still searching. Thanks for the input.
  14. Hello everyone, I'm at a loss here, hence the vague title I'm writing an application which is nearing its first RC version, hurray! Right now I'm going through the things that can be improved on, and one of them is the following: I've got a couple of forms with a "Client" field which is a <select> input. The problem here is that when the client list becomes bigger, so will the select input, something like over nine thousand clients would be scary. So I was thinking of using a paginated table where the user could browse the available clients and upon clicking the client's name, it would fill the form with a value. That much is easy... but whenever the user selects another page, since the page reloads.. all the data previously filled gets erased, which is a pain in the rear. I was thinking of using a GET form to control the pagination, and that way the fields' variables would remain intact. I have yet to implement this but its probably not hard to do... but it sounds extremely clunky and I'm pretty sure there's some fancy solution out there. Any suggestions? Very appreciated. Happy New Year
  15. Thanks for the help I'm no longer having any errors, I got it fixed before I saw your message. Thanks a lot though, I appreciate it.
  16. Hello everyone I found this very useful set of functions at http://www.spaceblue.com/codedetail.php?CodeID=1 and have been using them for interacting with MySQL. I ran into a problem when trying to use the MySQLSelect() function however. The function code is: // Build Select query (EXPERIMENTAL) // $table - Is name of table to select from // $columnsArray - Is an indexed array of column names to select. May also be a string if special select from clause or false for all columns // $whereArray - Is an associative array of names => values, may be false for no where clause, or a string if special where clause // $link - If false, will return the built query as a string function MySQLSelect( $table, $columnsArray = false, $whereArray = false, $compareArray = false, $orderByArray = false, $orderAscending = false, $link = false ) { // Check that if $CompareArray is an array, it is the same size as $whereArray if( is_array($compareArray) ) { if( !is_array($whereArray) ) return MySQLDie("SELECT ERROR: whereArray must be an array since compareArray is an array."); if( count($compareArray) != count($whereArray) ) return MySQLDie("SELECT ERROR: compareArray and whereArray must have same mumber of items."); } MySQLAddSlashes( $whereArray ); // Add slashes to array values $query = "SELECT "; // Specify columns to select if( is_array($columnsArray) ) { $bIncludeComma = false; while(list(,$column) = each($ColumnsArray) ) { if( $bIncludeComma ) $query .= ", "; $query .= "`$column`"; $bIncludeComma = true; } $query .= " "; } else if( $columnsArray ) { $query .= "$columnsArray "; } else { $query .= "* "; } $query .= "FROM `$table`"; // specify where clause if( is_array($whereArray) ) { $count = 0; $query .= " WHERE"; while( list($column, $value) = each($whereArray) ) { if( $count > 0 ) $query .= " AND"; // If you want more than this, you really should make the query yourself $query .= "`$column` "; if( is_array($compareArray) ) $query .= $compareArray[$count]; else if( $compareArray ) $query .= "$compareArray"; else $query .= "LIKE"; if( $value === null ) $query .= " NULL"; else $query .= " '$value'"; $count++; } } else if( $whereArray ) { $query .= " WHERE $whereArray"; } // specify order by clause if( is_array($orderByArray) ) { $bIncludeComma = false; while(list(,$column) = each($orderByArray) ) { if( $bIncludeComma ) $query .= ", "; $query .= "`$column`"; $bIncludeComma = true; } if( $orderAscending ) $query .= " ASC"; else $query .= " DESC"; } else if( $orderByArray ) { $query .= " ORDER BY $orderByArray"; } if( $link ) return mysql_query($query, $link ) or die("SELECT ERROR ($query): " . mysql_error() ); return $query; } I am calling the function using: (right now just trying to echo the query) $table = "users"; $fields = array("user_ID", "username"); $query = MySQLSelect($table, $fields); echo $query; An error saying "Variable passed to each() is not an array or object" pops up when I run my code. I am fairly certain I am using an array to indicate the fields, but I don't quite understand what I'm doing wrong. The function allows $fields to be a string, so something like $fields = "user_ID, username" will work just fine, but I wanted it to work as an array as the code is much more readable to me atleast. The comments on the function suggest using an array too... I'm just not seeing where I went wrong, I must confess I don't quite grasp why they use the each() in there either, but that's beside the point. Can anyone help?
  17. The thing is, if an "event" starts on 10/12/2008 and ends on 12/12/2008, there will be 3 entries on the database: 1 - Client, Place, Hour, 10/12/2008 2 - Client, Place, Hour, 11/12/2008 3 - Client, Place, Hour, 13/12/2008 Now, if the end date is undetermined... how will I fill the database correctly? Each "event" has to be stored on the database as a unique entry, these aren't really "events" per-se, they are more like "interventions". There is probably a much better way to do all this...
  18. Hello everyone. I'm building a calendar system for a client and have finally gotten to the recurring events which I was dreadfully fearing, and now the beast is showing its fangs. Alright, first a little explanation on how it works, its pretty straightforward... each event is stored in the database, within the table "events" I have multiple fields, including starting hour, ending hour, starting date, ending date and "recurring" which can be 0 or 1. So, each event has its own "identity" in the database. The user can specify an end date and also how often it repeats or on which days, in any case the problem I face now is, for recurring events... if an event has an undetermined end date - which happens oftenly - it would naturally be impossible to insert infinite number of events on the database. Anyone have a suggestion? I have seen this be done on many calendar systems... just have no idea on how to take the first step in the right direction. I have thought about Cron Jobs but I steer clear away from cron jobs usually... I'd much rather do it all programactically... I'm never comfortable with CJ... Thank you for any tips!
  19. I have found a solution to this problem, here is a snapshot of what I was able to achieve with the help of a friend of mine: [attachment deleted by admin]
  20. I require that the day-view be displayed like the image I uploaded. The month and week views aren't done yet, they aren't even that important for now. I have finally reached a point where I can safely breathe... I think I found a solution using multiple dimension arrays, thanks to a friend of mine who gave me a push in the right direction. I still need to tinker with it however.
  21. I'm not sure what you mean...? That would mean the world to me, ProjectFear. I am getting more and more confused as I keep poking around see what I can come up with. The biggest problem I have is knowing whether an event is overlapping or not, because this check needs to be done at run time like I said, I am all sorts of confused ???
  22. Hello! First of all, I am sorry if this isn't the right place to post this... but here goes. I've been trying for the past few days to accomplish something that I finally deemed out of my league when it comes to programming. I need to create/generate a graphical display that shows when and where a team needs to be at a certain time in a day. My MYSQL Table returns the following information: TEAM_ID | CLIENT / LOCATION | BEGIN HOUR | END HOUR | DAY | 1 | FOO | 8 | 11 | 2008-06-07 | 1 | BAR | 9 | 12 | 2008-06-07 | 2 | FOO | 10 | 13 | 2008-06-07 | 2 | JOE | 15 | 18 | 2008-06-07 | 3 | FOO | 18 | 20 | 2008-06-07 | 3 | JOE | 10 | 19 | 2008-06-07 | 4 | BAR | 8 | 14 | 2008-06-07 | I can display this information easily, but my client needs it to be displayed graphically. I've ran into some problems trying to do it by myself, mainly due to overlapping events (which are allowed to occur), therefore I wanted to ask anyone out there to see if they had a suggestion I could follow, a tutorial or some other type of help, anything would be greatly appreciated. ps, Because there will be recurring events, the check for overlapped events needs to be done at "runtime", I have no idea how to achieve this... I've added a picture to illustrate the required output. [attachment deleted by admin]
×
×
  • 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.