-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
updating multiple array daya with selection and checkbox values
Barand replied to mythri's topic in PHP Coding Help
If the second checkbox is not checked it is not posted, so the third checkbox will be the second in your POST array and no longer corresponds to the correct items in the other arrays (which are always posted) I would use the enroll_no to tie them together eg <select name='class[enroll_no]' > <select name='section[enroll_no]' > <input name="selector[enroll_no]" ... > -
If there is an error when the query is submitted, the change I suggested will output the error message plus your query (in the variable $query) exactly as it was submitted. What are you expecting in between $query?
-
As Mac_gyver suggested, but go back about 10 years in the documentation as your code looks as though it was relying on register_globals being ON and that was deprecated about a decade ago.
-
Are you aware that check box values are only posted if they are checked? If unchecked it will not post a zero value Use $mott = isset($_POST['mott'] ? $_POST['mott'] : 0;
-
Check if any errors $res = mysql_query($query)or die (mysql_error() . "<pre>$query</pre>");
-
Basically, $id = intval($_GET['id']); and the query is DELETE FROM student_information WHERE student_id = $id
-
Look it up in the documentation for your particular datepicker. If there is none, use one that has. http://api.jqueryui.com/datepicker/#option-dateFormat PS: I prefer to set datepickers to use "31 Jan 2014" format as it is clear to the user, unambiguous and recognised by strtotime()
-
If you use an aggregation function, such as MAX, you will get 1 row returned containing the max value, even if that value is 0
-
Here's sample code using baaSelect class <?php $db = new mysqli(HOST,USERNAME,PASSWORD,'test'); // use your credentials include('baaSelect.php'); /* UNCOMMENT BLOCK TO CREATE TEST DATA *************************************** $sql = "CREATE TABLE jpop_cat ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, cat_desc varchar(20) )"; $db->query($sql); $sql = "INSERT INTO jpop_cat (cat_desc) VALUES ('Fruit'), ('Vegetables'), ('Junk food') "; $db->query($sql); $sql = "CREATE TABLE jpop_food ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, cat_id INT, food_desc varchar(20) )"; $db->query($sql); $sql = "INSERT INTO jpop_food (cat_id,food_desc) VALUES (1,'Apple'), (1,'Banana'), (1,'Cherry'), (2,'Cabbage'), (2,'Potato'), (2,'Swede'), (3,'Burger'), (3,'Deep fried Mars bar'), (3,'Turkey twizzler') "; $db->query($sql); *******************************************************************************/ // create baaselect object $sel = new baaSelect(DB_MYSQLI, $db); // create the 2 menu objects $sel->addSelect('catmenu', 'jpop_cat', 'id', 'cat_desc', '', BY_ID, '--category--'); $sel->addSelect('foodmenu', 'jpop_food', 'id', 'food_desc', 'cat_id', BY_TEXT, '--food item--'); ?> <html> <head> <meta name="generator" content="PhpED 12.0 (Build 12010, 64bit)"> <title>Example baaSelect</title> <meta name="author" content="Barand"> <meta name="creation-date" content="05/13/2014"> <?php $sel->makeScript(); // create required js code and arrays ?> </head> <body> <form method='get'> Food category <?php $sel->makeSelect('catmenu'); ?> <br><br> Food item <?php $sel->makeSelect('foodmenu'); ?> <br><br> <input type='submit' name='btnSubmit' value='Submit'> </form> </body> </html>
-
'Fraid not. The selection is done on the client after php has finished running on the server (which could be on a different continent). So it has to be done on the client using javascript or by communicating with the server via ajax Other way is to show form with first menu only. User makes selection and submits form. Form is then displayed again with second menu as well. But this requires rebuilding the page each time.
-
My class was designed for hierarchical data structures (eg, country/region/city or manufacturer/model/engineSize). It requires the table indexes to be numeric. It doesn't use ajax, it generates the js functions to handle the selection and build the arrays. If you want an Ajax solution, I posted an example application yesterday for handling database/tables/columns http://forums.phpfreaks.com/topic/288437-how-to-update-all-databases/?do=findComment&comment=1479216
-
-
Do both/all products go through the same production steps?
-
Then I suggest you re-read my post
-
SELECT .... ORDER BY whatever DESC
-
Removing only the first line break at the beginning of string
Barand replied to Texan78's topic in PHP Coding Help
You could float the div element to the right <html> <head> <title>test</title> <style type='text/css'> div { float: right; } </style> </head> <body> <?php echo $tData;?> </body> </html> -
I'd move the <table> and <tbody> to before the while loop and move the </table> to after the loop. Unless, of course, you specifically want each item in its own table and not just a row in a single table.
-
You do if you have the same column names in both tables otherwise you get an ambiguous column name error. And purely as a form of documentation I prefer to be explicit about which tables the columns are coming from
-
The query would be something like this SELECT c.id as catid , c.name , g.id as gameid , g.title , g.thumbnail , g.description , g.plays , g.active FROM categories c INNER JOIN games g ON c.id = g.category AND g.active='1' WHERE c.active = 'yes' AND c.home='yes' ORDER BY catid DESC , gameid DESC
-
You need to loop throught the items, not the channel $xml = simplexml_load_file($lane_data); $incident_data_date = $channel->pubDate; $incident_data_updated = DATE("D, M d, g:i a", STRTOTIME($incident_data_date)); foreach($xml->channel->item as $item) { $incident_data_title = $item->title; $incident_data_desc = $item->description; echo 'Title: ' . $incident_data_title . '<br>'; echo 'Desc: ' . $incident_data_desc . '<br>'; echo 'Date: ' . $incident_data_date . '<br>'; }
-
You should be using a single query, joining the two tables, and not running queries inside a loop.
-
Probably because you use $query for both sets of query results, the second overwriting the first