Jump to content

MattR

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Everything posted by MattR

  1. Really cannot see why this doesn't work. $text = "<div id=\"page\"> <div class=\"item\"> Test </div> </div>"; preg_match("#<div id=\"page\"><div class=\"item\">(.*?)</div></div>#m", $text, &$match); var_dump($match); Output: array(0) { } Why??
  2. MattR

    Vertical align

    Don't now how much time I've spent Googling and trying stuff but I just can't get this to work and it's infuriating me. All I want is to have text in a div vertically aligned. #message2-box { position: absolute; left: 0; width: 1024px; height: 300px; top: -144px; background: #c0c0c0; border-top: 2px #000000 solid; border-bottom: 2px #000000 solid; opacity: 1; vertical-align: middle; display: table; margin-top: auto; margin-bottom: auto; } #message2-text { font-family: "Trebuchet MS"; font-size: 1024px; text-align: center; color: #000000; position: absolute; left: 0; width: 1024px; vertical-align: middle; display: table-cell; height: 300px; margin-top: auto; margin-bottom: auto; } #horizon { position: absolute; top: 50%; left: 0px; width: 100%; height: 1px; overflow: visible; visibility: invisible; display: block; vertical-align: middle; } And neither this: <div id="horizon"><div id="message2-box" style="z-index: 3;"><div id="message2-text" style="z-index: 4;">Text here.</div></div></div> or this: <div id="horizon"><div id="message2-box" style="z-index: 3;"><table style="width: 100%; height: 300px;"><tr><td id="message2-text" width="100%" height="300px" align="center" valign="middle"><div style="z-index: 4;">Text here.</div></td></tr></table></div></div> align it vertically. Why?? Edit: Doesn't like the position: absolute; in the #message2-text class. I love how I always find the solution within minutes of asking for help. Such is life.
  3. I'm using phpMyGraph and I've run into a problem. I'm making a graph for temperatures over the day, and filling in any missing data with blanks (i.e. if it's only 12 noon, 13:00 - 23:00 get inserted with empty data/empty bars so the bars are all proportionate). Array for the actual data I've got: Array ( [00] => -1.4 [01] => -1.2 [02] => -1.5 [03] => -2.3 [04] => -3.2 ) Basically just data from midnight to 04:00. It draws fine like this, all the bars are below the 0 line, but they're all very thick and take up the entire width of the graph, as that's all the data there is; see first attachment, (ignore the chopped off title), it's spreading it out and it isn't very clear. So, for the other hours I just loop through and populate it with 0, just so there's an empty space for each one: Array ( [00] => -1.4 [01] => -1.2 [02] => -1.5 [03] => -2.3 [04] => -3.2 [05] => 0 [06] => 0 [07] => 0 [08] => 0 [09] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 0 [16] => 0 [17] => 0 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 0 [23] => 0 ) What I'd expect to see is the bars from before with the bars from 05-23 there as well, but empty. This method works fine, other graphs are OK, the problem is that if the first value is a negative, and there is a 0 anywhere in the data after that, no bars will show at all, see second attachment. If I put a positive number at the start, they show fine, if I have a negative at the start and replace the 0 with 0.0000001, it's fine, it's only if it starts with a negative and contains a 0. Putting 0.0000001 instead of 0 is not a solution as then the value on the bar is 1E-12 or something. I've looked at the code and can't see why it happens, if anyone can I'd be very grateful. Apart from this issue the class is very good. Unfortunately though there doesn't seem to be a clear way of contacting the author via their website. Thanks. [attachment deleted by admin]
  4. Ah, so simple!! Thank you. One more question, if it returns more than one value, how would I go about getting them all?? For example, if COUNT(*) is 28 but there's more than 1 qid with a count of 28, how could I get all of the qids with a count of 28?? If I remove the LIMIT 1 it returns everything.
  5. Yeah, try this: $query = mysql_query("SELECT COUNT(*) FROM `ac_users` WHERE `username` = '$q'") or die(mysql_error());
  6. Change INSERT INTO to REPLACE INTO?? Unless I'm misunderstanding what you mean.
  7. Read the rules, this is what's applicable. I have a table that records an ID and a time, and some other stuff that isn't relevant here: +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+----------------+ | rid | int(11) | NO | PRI | NULL | auto_increment | | qid | int(11) | YES | | NULL | | | location | varchar(255) | NO | | NULL | | | extralocation | text | NO | | NULL | | | time | int(10) | NO | | NULL | | +---------------+--------------+------+-----+---------+----------------+ Records: +------+------------+ | qid | time | +------+------------+ | 299 | 1256679944 | | 147 | 1256679948 | | 69 | 1256679949 | | 218 | 1256679969 | | 3 | 1256679975 | | 10 | 1256680053 | | 140 | 1256680068 | | 249 | 1256680096 | | 236 | 1256680103 | | 64 | 1256680119 | +------+------------+ ... etc etc. Times are old but it's just an example. Query that I found on the internet: SELECT `qid`, COUNT(*) AS 'Last24Hours' FROM `lost_records` WHERE `time` BETWEEN '1257721753' AND '1257808153' GROUP BY `qid` ORDER BY 'Last24Hours' DESC LIMIT 1; MySQL 5.1.40 Basically I want to find the most common qid over the last day. It physically works, there's no errors, but it's not always accurate. For example, it returned qid 1 and the count was 1, but there were some qids where 3+ times. Anyone see what's wrong with it??
  8. This is my form: <body> <script type="text/javascript"> function ajaxFunction() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { document.location.address.value=xmlhttp.responseText; } } xmlhttp.open("GET","postcodes.php",true); xmlhttp.send(null); } </script> <form method="get" name="location" action=""> <input type="text" name="postcode" size="8" maxlength="8" onkeyup="ajaxFunction();" /> <input type="textarea" name="address" value="" rows="5" /> </form> </body> That's pretty much copied from W3Schools. This is the 'postcodes.php' file: if($_GET) { echo "YES"; } else { echo "NO"; } Whatever I type into the 'postcode' form box, the 'address' one says NO. Whatever I put in. I know it's finding the file .php because it's outputting something, but why is it refusing to find the GET request??
  9. Ha, something so simple, got it working, thank you
  10. This is the code I have: function EpisodeList() { $episodesexploded = explode('||', $episodes); foreach ($episodesexploded as $episode) { echo $episode . "<br />"; } } $episodes is an array from a query. The error I get is: Notice: Undefined variable: episodes in /file.php on line 85 Can't figure out why ???
×
×
  • 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.