Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. 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]" ... >
  2. 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?
  3. 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.
  4. 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;
  5. Check if any errors $res = mysql_query($query)or die (mysql_error() . "<pre>$query</pre>");
  6. Basically, $id = intval($_GET['id']); and the query is DELETE FROM student_information WHERE student_id = $id
  7. 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()
  8. 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
  9. 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>
  10. '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.
  11. 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
  12. Probably want something like this
  13. Do both/all products go through the same production steps?
  14. Then I suggest you re-read my post
  15. SELECT .... ORDER BY whatever DESC
  16. 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>
  17. ... and it might be a good idea to create the $songs variable before you try and put it in the JS array.
  18. 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.
  19. 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
  20. 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
  21. Basic HTML - Links use <a>....</a> tags. <a href='{$row['link']}'>Click here</a> varchar(N) should be fine for storing a link, where N is the max size you need to store
  22. 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>'; }
  23. You should be using a single query, joining the two tables, and not running queries inside a loop.
  24. Probably because you use $query for both sets of query results, the second overwriting the first
×
×
  • 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.