Jump to content
Old threads will finally start getting archived ×

Barand

Moderators
  • Posts

    24,599
  • Joined

  • Last visited

  • Days Won

    828

Everything posted by Barand

  1. use 'd/m/Y' then see date
  2. Continue to save dates in your database as yyyy-mm-dd as other formats are useless for date comparisons, sorting and use of mysql date functions. To output as dd/mm/yy you have 2 options 1. format in the query using DATE_FORMAT() function in mysql SELECT DATE_FORMAT(datefield, '%d/%m/%y') as date ... 2. use php date() function echo date('d/m/y', strtotime($dbdate));
  3. I would seriously recommend you change your column and table name 1. Use something meaningful 2. Don't use spaces in identifiers. If you really must you need backticks around the name. Also, as already pointed out, you have other syntax errors. The result of a query is a result resource and cannot be echoed as a variable. You need to fetch rows from the result them echo the content of the row. $result=$mysqli_query("SELECT `COL 4` FROM `TABLE 1` WHERE $clientIP BETWEEN `COL 1` AND `COL 2`"); $row = mysqli_fetch_assoc($result); echo $row['COL 4'];
  4. or just sort the array on descending values of score function mysort($a, $b) { return $b[1] - $a[1]; // for ASC sort on element 1 (score), reverse a and b } usort($array, 'mysort'); // sort the array DESC The highest score will be the record at $array[0]
  5. the purpose of these lines SUM(IF(f.fileStatus=0,1,0)) as tot0, SUM(IF(f.fileStatus=1,1,0)) as tot1, is to count the number of rows with fileStatus 0 and 1. I do not understand what your additions do ie SUM(IF(f.fileStatus=2,1,2)) as tot2, SUM(IF(f.fileStatus=0,2,1)) as tot3,
  6. Odd. After fixing the XML, my output was ID: 26 Tilt: 30 ID: 27 Tilt: 50 ID: 28 Tilt: 50
  7. TIMESTAMP default values can be CURRENT_TIMESTAMP (auto insert current datetime on INSERT) CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP (auto insert current datetime on INSERT and UPDATE)
  8. try SimpleXML $xml = simplexml_load_file('equip.xml'); foreach ($xml->xpath('//Equipment') as $eq) { echo "ID: {$eq->Id}<br>"; foreach ($eq->Characteristic as $c) { if ($c->CharacteristicName == 'Tilt') { echo "Tilt: {$c->CharacteristicValue}<br>"; } } echo '<br>'; }
  9. That xml is missing several </characteristic> tags
  10. Your form has no submit button so how are you sending the selected value?
  11. No quotes if numeric value, and $category_id probably is, as is the $price
  12. $fleetarray[$a]["w$b"]
  13. You won't know if there is an error unless you echo the message
  14. You could use a query like this SELECT user , GROUP_CONCAT(short_link) as short_links , server , format , SUM(size) as size , resolution FROM table_name WHERE type = 'tutorials' and type2='word' and video_id='01' GROUP BY user, server However, your sizes need to be stored as INT (eg value 100) and not as VARCHAR (eg value 100MB) When processing, explode the "short_links" field.
  15. simpler alternative <form id="inputForm" name="inputForm" method="POST" action="code-login.php"> <p>Grab some coffee: <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="submit" value="Crack the Code!" /> </p> </form> then <?php $correct = array ('##', '##', '##', '##'); if (isset($_POST['input'])) { if ($_POST['input'] == $correct) { header("Location: http://www.someotherpage.com/"); exit; } else { echo "Code is incorrect<br>"; } } ?>
  16. The best method is don't use dynamic tables. Use a single table with the date in the records.
  17. One way (anniversaries in the next seven days) SELECT thedate FROM dates WHERE DATE_FORMAT(thedate,'%m%d') BETWEEN DATE_FORMAT(CURDATE(),'%m%d') AND DATE_FORMAT(CURDATE() + INTERVAL 7 DAY,'%m%d') edit : caution - it won't work if 7-day range spans year end
  18. check for errors $sql = "SELECT * FROM table WHERE id=$id"; $res = mysql_query($sql); if (!$res) die(mysql_error());
  19. See web_craftsman's reply $sql = "SELECT * FROM table WHERE id=$id"; $res = mysql_query($sql);
  20. 1. Use code tags (or <> button) when posting code. 2. post the actual error message
  21. try <?php session_start(); $cal = ""; if(isset($_GET["cal"]) and isset($_GET["num1"]) and isset($_GET["num2"])) { if ( $_GET["cal"] == "+" ) $cal = $_GET["num1"] ."+". $_GET["num2"] ."=".(($_GET["num1"] + $_GET["num2"])); elseif ( $_GET["cal"] == "-" ) $cal = $_GET["num1"] ."-". $_GET["num2"] ."=".(($_GET["num1"] - $_GET["num2"])); elseif ( $_GET["cal"] == "/" ) $cal = $_GET["num1"] ."/". $_GET["num2"] ."=".(($_GET["num1"] / $_GET["num2"])); elseif ( $_GET["cal"] == "*" ) $cal = $_GET["num1"] ."*". $_GET["num2"] ."=".(($_GET["num1"] * $_GET["num2"])); $_SESSION['results'][] = $cal; // store in session array } ?> <!DOCTYPE html> <html> <head><title> test </title> </head> <body> <h1> Enter Comment </h1> <form action="" method="get"> Number1: <input type="text" name="num1"> Number2: <input type="text" name="num2"> <select name="cal"> <option value="+"> + </option> <option value="-"> - </option> <option value="/"> / </option> <option value="*"> * </option> </select> <input type="submit" value="Do Math"> </form> <?php // print stored session array if (isset($_SESSION['results'])) { foreach ($_SESSION['results'] as $res) { echo $res . '<br>'; } } ?> </body> </html>
  22. Just replace the single array element if(empty($details_array["propview"])) { $details_array["propview"] = "No Contingencies"; }
  23. No, they shouldn't. An id is a unique identifier for a record, not a sequence number, and should not change for the life of that record. Nor should the ids of deleted records be reallocated to new records. If you need to maintain the sequence that that the records were added use something else, like a timestamp.
  24. mysql_fetch_array Plenty of examples
×
×
  • 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.