-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
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
-
How should I organize data for a graph from MySQL data?
Barand replied to jdlev's topic in MySQL Help
You would select the data with a WHERE clause such as "WHERE datefield BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()". How you then store the results for a graph would depend on the requirements of the software you are using to produce the graph -
something like this? SELECT SUM(IF(shift_id IN (1,3,5), IF(shift_id=5, compound_output/2,compound_output),0)) as val1, SUM(IF(shift_id IN (2,4,5), IF(shift_id=5, compound_output/2,compound_output),0)) as val2 FROM op_output;
-
Use a while() loop $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result) ) { echo ... }
-
Better to check if it is set also $par = (isset($_GET['par1']) && !empty($_GET['par1']) ) ? $_GET['par1'] : 4;
-
You should check the output from mysql_error() function and you will find you have a syntax error in the query. "TO" is a mysql reserved word. If you must use it as a column name it needs to be inside backticks (`to`)
-
Jessica's CRUD tutorial should be of help http://thewebmason.com/php-mysql-crud-tutorial-using-pdo-create-read-update-delete-part-4-delete/
-
"desc" is a reserved MySql word. Either change it (recommended) or enclose it in backticks in your queries eg `desc`
-
you have mysql_select_db("jobs"); you need to select the database that contains the jobs table
-
You are testing for missing fields before you get the values from the POST array
-
You could try using realpath
-
Error in this line <input type=expiry name= maxlength=15 size=15><br /><br /> Also values should be quoted eg type="text" But your main problem is that your reference book seems to be 10 years out of date (look up register_globals) and you need to pick up the posted values from the $_POST array $title = $_POST['title']; etc