-
Posts
24,599 -
Joined
-
Last visited
-
Days Won
828
Everything posted by Barand
-
use 'd/m/Y' then see date
-
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));
-
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'];
-
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]
-
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,
-
How to read ALL data with XPath/XML/PHP from XML
Barand replied to PriteshP23's topic in PHP Coding Help
Odd. After fixing the XML, my output was ID: 26 Tilt: 30 ID: 27 Tilt: 50 ID: 28 Tilt: 50- 5 replies
-
- xml
- domdocument
-
(and 2 more)
Tagged with:
-
having problems loading mysql into myphpadmin error
Barand replied to fastz28's topic in PHP Coding Help
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) -
How to read ALL data with XPath/XML/PHP from XML
Barand replied to PriteshP23's topic in PHP Coding Help
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>'; }- 5 replies
-
- xml
- domdocument
-
(and 2 more)
Tagged with:
-
How to read ALL data with XPath/XML/PHP from XML
Barand replied to PriteshP23's topic in PHP Coding Help
That xml is missing several </characteristic> tags- 5 replies
-
- xml
- domdocument
-
(and 2 more)
Tagged with:
-
Fetch db data depending on selected drop down value
Barand replied to cainam29's topic in PHP Coding Help
Your form has no submit button so how are you sending the selected value? -
Inserting values from a dynamic drop down list into Database
Barand replied to tahakirmani's topic in PHP Coding Help
No quotes if numeric value, and $category_id probably is, as is the $price -
$fleetarray[$a]["w$b"]
-
Inserting values from a dynamic drop down list into Database
Barand replied to tahakirmani's topic in PHP Coding Help
You won't know if there is an error unless you echo the message -
mySQL group by value depending on another value
Barand replied to 2260419's topic in PHP Coding Help
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. -
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>"; } } ?>
-
The best method is don't use dynamic tables. Use a single table with the date in the records.
-
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
-
check for errors $sql = "SELECT * FROM table WHERE id=$id"; $res = mysql_query($sql); if (!$res) die(mysql_error());
-
See web_craftsman's reply $sql = "SELECT * FROM table WHERE id=$id"; $res = mysql_query($sql);
-
1. Use code tags (or <> button) when posting code. 2. post the actual error message
-
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>
-
Just replace the single array element if(empty($details_array["propview"])) { $details_array["propview"] = "No Contingencies"; }
-
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.
-
mysql_fetch_array Plenty of examples