Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. You can have as many joins as you need. What is going wrong?
  2. Put the phrase inside double quotes and use BOOLEAN MODE SELECT * FROM tablename WHERE MATCH (textfield) AGAINST ('"acura integra radiator"' IN BOOLEAN MODE); http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
  3. Put "\n" in the string to replace the spaces. When you output in the browser use echo nl2br($promo); which will put <br> where the \n are
  4. I'll rephrase that^^ Let me have test data dumps for those 2 tables that will illustrate your problem then I can work on the query.
  5. Wrong syntax for update query. Should be UPDATE table SET Col1 = 'val1' , Col2= 'val2' , etc WHERE ...
  6. Have you got test data dumps for those 2 tables that will illustrate your problem?
  7. foreach ($xaxis as $k => &$v) { $a = (array)$v; $v = $a[0]; } echo '<pre>',print_r($xaxis, true),'</pre>'; result Array ( [0] => 1 [1] => 6 [2] => 11 )
  8. Define "not working". what is it doing that it shouldn't do? what is it not doing that it should do?
  9. You have already posted on this topic. DON'T DOUBLE POST
  10. Well, if you are storing the datetime in microseconds then your code should be OK $newdate2 = strtotime ( '-7 day' ) * 1000 ; then $sql = "SELECT logtime FROM tablename WHERE logtime BETWEEN $newdate2 AND UNIX_TIMESTAMP()*1000";
  11. You would have more success if the logtimes were valid unix time values - they are 3 digits too long The value in your example (001367596058040) is valid if the final 040 is removed mysql> SELECT FROM_UNIXTIME('001367596058040'); +----------------------------------+ | FROM_UNIXTIME('001367596058040') | +----------------------------------+ | NULL | +----------------------------------+ mysql> SELECT FROM_UNIXTIME('001367596058'); +-------------------------------+ | FROM_UNIXTIME('001367596058') | +-------------------------------+ | 2013-05-03 16:47:38 | +-------------------------------+
  12. Or you can use the object versions of mysqli $query = "SELECT * FROM a_playerRank WHERE YEAR='2014' AND commit='1' AND state='IN' ORDER BY nameLast"; $results = $mysqli->query($query); $count = $results->num_rows; echo '<div class="commit_list">'; echo "There are $count kids committed.";
  13. Are you storing logtime in a varchar() column instead of int? You wouldn't get the leading zeros in a numeric type field. It's a lot easier to store dates as type DATE (format yyyy-mm-dd). That's why it's there. Then it's just $days = 2; // or 1 or 7 $sql = "SELECT whatever FROM tablename WHERE logtime BETWEEN CURDATE() - INTERVAL $days DAY AND CURDATE() "; You can still do a similar query but you now have to convert your unix date to a real date first (every record every query using logtime comparisons) $days = 2; // or 1 or 7 $sql = "SELECT whatever FROM tablename WHERE FROM_UNIXTIME(logtime) BETWEEN CURDATE() - INTERVAL $days DAY AND CURDATE() ";
  14. Please put your code in the forum's code boxes (the <> button in the replay toolbar) Check boxes use "checked='checked'". Dropdowns use "selected='selected'"
  15. I recommend that you read the manual for mysql_query, mysql_num_rows and mysql_fetch_array and look carefully at what parameters they require and what they return. edit: and turn error_reporting on.
  16. Apart from the join definitions I couldn't see obvious errors but then I don't know your table definitions select `g`.`groupID` AS `groupID`, `g`.`groupName` AS `groupName`, `g`.`groupPermissions` AS `groupPermissions`, `gd`.`permissionID` AS `permissionID`, `gd`.`type` AS `type`, `gd`.`groupKey` AS `groupKey`, `gd`.`value` AS `value`, `u`.`userID` AS `userID`, `u`.`userName` AS `userName`, `u`.`firstName` AS `firstName`, `u`.`lastName` AS `lastName`, `u`.`middleInitial` AS `middleInitial`, `u`.`password` AS `password`, `u`.`email` AS `email`, `u`.`address` AS `address`, `u`.`address2` AS `address2`, `u`.`city` AS `city`, `u`.`state` AS `state`, `u`.`zip` AS `zip`, `u`.`registeredBy` AS `registeredBy`, `u`.`registerDate` AS `registerDate`, `u`.`lastLogin` AS `lastLogin`, `u`.`permissions` AS `permissions`, `u`.`superUser` AS `superUser` from `c41ATSer3db`.`er3-groups` `g` join `c41ATSer3db`.`er3-group-definitions` `gd` ON `gd`.`groupKey` = `g`.`groupID` join `c41ATSer3db`.`er3-users` `u` ON `u`.`userID` = `gd`.`value` where (`g`.`groupName` = 'Administrator') and (`gd`.`type` = 'user') BTW, all those column aliases are superfluous.
  17. try SELECT si.invoiceNo, si.soldOn, cs.statusCode FROM sapImport si INNER JOIN conStatus cs ON si.id = cs.record INNER JOIN ( SELECT record, MAX(id) as id FROM conStatus GROUP BY record ) mx ON cs.record = mx.record AND cs.id = mx.id
  18. Where is "store" held? I don't see that column in your data
  19. so use $myData->addPoints($datatimes,"Series1"); echo '<pre>'; print_r( Array(17,14,11,11,7,5) ); echo '<pre>'; produces Array ( [0] => 17 [1] => 14 [2] => 11 [3] => 11 [4] => 7 [5] => 5 ) exactly the same as Requinix's array
  20. That code would produce only part of the page, so ??? As for normalizing data, see http://forums.phpfreaks.com/topic/273634-best-way-to-set-up-tables-when-multiple-values/?do=findComment&comment=1408360
  21. try $ALLTW = mysql_query("SELECT DISTINCT TW FROM ( SELECT TW from TABLE UNION SELECT TW2 as TW from TABLE UNION SELECT TW3 as TW from TABLE ) subq ORDER BY TW"); while($row = mysql_fetch_assoc($ALLTW)) { echo "<option value='" . $row['TW'] . "'>" . $row['TW'] . "</option>"; } If you correctly normalized your data there would be no need for the UNIONs
  22. Is this data from a database? If not, why not?
  23. This version worked with the test data that I set up. The ONLY THING you should need to change are the mysql_connect() credentials. function top10news($s, $t, $u, $w) { session_start(); $con = mysqli_connect("**********", "*************", "***************", "************"); if (mysqli_connect_errno($con)) { echo "<p class='sect'>Could not connect to DB</p>"; } else { $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage,imageposition FROM newsitem INNER JOIN newsbusiness ON newsitem.niid=newsbusiness.niid LEFT JOIN newsimage ON newsitem.niid=newsimage.niid WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' "; if ($u != "Any") { $q = $q . "AND sitename='$u' "; } if ($s != "Any") { $parts = explode('-', $s); $y = $parts[0]; $m = $parts[1]; $q = $q . "AND YEAR(newsdate) = $y AND MONTH(newsdate) = $m "; } $q = $q . "ORDER BY newsdate DESC LIMIT 0,10"; $result = mysqli_query($con, $q); while ($tnrow = mysqli_fetch_array($result)) { echo " <div class='newssummary'>"; if ("" . $tnrow ['newsimage'] . "" == "none") { echo "<p class = 'newsmore' > <a href = 'newsitem.php?i=" . $tnrow['niid'] . "' > Read More</a > </p>"; } else if ($tnrow ['imageposition'] == 'Centre') { echo "<p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } else if ($tnrow ['imageposition'] == 'Right') { echo "<p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } else if ($tnrow ['imageposition'] == 'Left') { echo "<p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } mysqli_close($con); } }
  24. Why did you change my query from $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage,imageposition FROM newsitem INNER JOIN newsbusiness ON newsitem.niid=newsbusiness.niid LEFT JOIN newsimage ON newsitem.niid=newsimage.niid WHERE newsstatus='enabled' "; back to $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage FROM newsitem,newsbusiness INNER JOIN newsbusiness ON newsitem.niid=newsbusiness.niid LEFT JOIN newsimage ON newsitem.niid=newsimage.niid WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' "; What is the point of me giving you the code then you rewriting it wrongly? I give up!
  25. A table dump should look like this example DROP TABLE IF EXISTS `clubvisit`; CREATE TABLE `clubvisit` ( `day_id` int(11) NOT NULL AUTO_INCREMENT, `dues` int(11) DEFAULT NULL, `last_visit` datetime DEFAULT NULL, `points` int(11) DEFAULT NULL, PRIMARY KEY (`day_id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; -- -- Dumping data for table `clubvisit` -- INSERT INTO `clubvisit` VALUES (1,900,'2012-12-01 20:00:00',6), (2,700,'2012-12-04 17:00:00',7), (3,600,'2012-12-07 10:00:00',4), (4,600,'2012-12-09 21:00:00',6), (5,600,'2012-12-10 15:00:00',6), (6,600,'2012-12-14 17:00:00',6), (7,500,'2012-12-10 20:00:00',5), (8,500,'2012-12-14 19:30:00',5); so it can be executed to create the table and load the data. Whatever gui front end you are using for your database admin (PHPMyAdmin, MySQL Workbench etc) should have a facility to create table dumps
×
×
  • 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.