- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 212
- Posts with Upvotes
- 159
- Upvoting Members
- 75
- Downvotes Received
- 8
- Posts with Downvotes
- 7
- Downvoting Members
- 7
Re: I think You need normalize DB-tables for first. create table Pensyarah( IDPensyarah integer not null primary key auto_increment , IDUser varchar(50) not null , NamaPensyarah varchar(100) not null , Email varchar(50) not null , NoTel varchar(11) not null ); create table Kursus( IDKursus integer not null primary key auto_increment , … | |
Re: Use recursive printing e.g. <?php function print_recursive($list){ echo '<ul>'; foreach($list as $item){ echo '<li id="'.$item['id'].'">'.$item['text']; if( isset($item['children']) ){ print_recursive($item['children']); } echo '</li>'; } echo '</ul>'; } print_recursive($list); ?> | |
| Re: In your examples 2 and 3 are missing final `}` on `while` loop |
Re: What about `require` - files exists on defined path? | |
Re: I think your mistake is comparing string and number ![SQLite.png](https://static.daniweb.com/attachments/4/7066cc9b4c0eb84ab280812562ca5270.png) You should be use `cast(strftime('%Y', HireDate) as number)<2003` | |
Re: I think your mistake is mixed use of variable names "searchdata" and "searchname" | |
Re: For first check your MySQL version select version() from dual; Because all `"mysql_..."` in current (MySQL 8.0.) is deprecated - probably you should be use `"mysqli_..."` instead | |
Re: 1. I recomend use prepared statement instead of directly put user input data to SQL query. 2. Use [SEND_LONG_DATA](https://www.php.net/manual/en/mysqli-stmt.send-long-data.php) to store blob into database. | |
Re: if you want to denormalize SQL table for search then you think wrong | |
Re: Use CSS e.g. input[type="button"][value="one"] { background: blue; } input[type="button"][value="two"] { background: red; } | |
Re: Radio buttons let a user select ONLY ONE of a limited number of choices Use same attribute "name" but array of values use as attribute "value" e.g. var div = document.createElement('div'); div.setAttribute('id','my_div'); document.body.appendChild(div); function addradio(){ const names=["abi","sam","tom"]; names.forEach( function(curr){ document.getElementById("my_div").innerHTML+='<br/>' +'<input type="radio" id="my_'+curr+'" name="names" value="'+curr+'" />' +'<label for="my_'+curr+'">'+curr+'</label>'; } ); … | |
Re: Your mistake is comma after `$_POST['JENIS_PERMINTAAN']`. If you want to handle as array `$_POST['JENIS_PERMINTAAN'], reverse_tanggal($_POST['TGL_PERMINTAAN'])` then include it in square brackets foreach([$_POST['JENIS_PERMINTAAN'], reverse_tanggal($_POST['TGL_PERMINTAAN'])] as $idx=>$val){ | |
Re: Manage date in SQL query: $id = $_GET['id']; $sql = "UPDATE apparatuur SET inlever_datum = date(current_date()+7), uitleen_datum = NOW() WHERE id= ? "; $stmt = $conn->prepare($sql); $stmt->bind_param('i', $id); $status = $stmt->execute(); | |
Re: Create event in database [MySQL event create](https://dev.mysql.com/doc/refman/8.0/en/create-event.html) | |
Re: and another question - why you do not use `pathinfo($file,PATHINFO_EXTENSION)` insead of `substr($file, strrpos($file, '.') + 1)` in line 4? | |
Re: Do not need write script for this. Actually its a single line command e.g. You have directory `dir1` which contains multiple files and `dir2` which is target to copy `cp dir1/* dir2/` copy all files | |
Re: @klaus.veliu - Safe version is $users=array("Vito","Joey","Vinny"); $prep=str_pad("?",count($users)*2-1,",?"); // produce string '?,?,?' $sql = "SELECT * FROM `users` WHERE `name` in (".$prep.")"; $stmt = $db->prepare($sql); $stmt->execute($users); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); or $users=array("Vito","Joey","Vinny"); $sql = "SELECT * FROM `users` WHERE FIND_IN_SET(`name`,?)"; $stmt = $db->prepare($sql); $stmt->execute([implode(",",$users)]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); | |
Re: Don't need `declare` - select values direct to fields DELIMITER // CREATE TRIGGER download_ins BEFORE INSERT ON download FOR EACH ROW begin set new.ip_address = inet_aton(new.`ADDRESS`); set new.vrefer=(select id from `ip_lookup` where inet_aton(new.`ADDRESS`) between ip_lookup.start and ip_lookup.end limit 1 ); END; // DELIMITER ; | |
Re: Actually it do not affect any changes - `on duplicate update ...` in your example supress error message. The same can be achieved with `insert ignore into table ...` | |
Re: I recommend use `join` instead of `subquery` if possible because join works faster. I think you have another table e.g. `products` which contains all product id. Select `product_id` from products and `left join` sale and purchase. Where clause exclude null values e.g. select p.product_id ,sum(s.quantity) sale ,sum(c.quantity) purchase from products … | |
Re: Get value from array by key `$temp['IP_ADDRESS']` but use of `between` in your code is wrong - should be convert by `INET_ATON` | |
Re: It's a very simple in single row: string='India is a democracy' print (' '.join([word for word in reversed(string.split(' '))])) | |
Re: MySQL: select date_format(now(), '%d-%m-%Y'); PostgreSQL: select to_char(now(), 'dd-mm-yyyy'); OracleSQL: select to_char(sysdate, 'dd-mm-yyyy') from dual; Clause `from dual` in Oracle is required, in MySQL is optional, in PG SQL not usable - raise error | |
Re: php function `time()` also return timestamp but what about it with a table create? | |
Re: You can add to CSS .PaperApplication { visibility: hidden; } for set element with class PaperApplication hidden by default. After click radio button function change it to visible. | |
Re: In JS months numbered from 0 to 11. Actually 11 is december. You can write simple function function addMonths(d,n){ var dt=new Date(d.getTime()); dt.setMonth(dt.getMonth()+n); return dt; } and then e.g. var d=new Date(); // current date var d1=addMonths(d,1); var d2=addMonths(d,2); var d3=addMonths(d,3); convert month number to 1-12 var n1=d1.getMonth()+1; var n2=d2.getMonth()+1; … | |
Re: In your example "0" is terminator but "0" allways incrases "even". Check `if(entNum==0){ break; }` after scanf. More convenient is binary compare to 1 for test even and odd in my opinion e.g. lines 15-22 you can replace to one line: `entNum & 1 ? odd++ : even++ ;` variable … | |
Re: Please post human readable HTML | |
Re: In your HTML code `<table>` not opened, table row `<tr>` not opened, invalid `<input>` tag without `>` - it should be something like if($result->num_rows > 0){ echo '<table>'; while ($row6 = $result->fetch_assoc()){ //table code// echo '<tr>'; echo '<td><input type="checkbox" name="check[]" value="'.$cato.'" /></td>'; echo '</tr>'; } echo '</table>'; } PHP code … | |
Re: Use backticks instead of apostrophes `attendence` AS 'type' ,`in_address` AS 'address_in' ,`out_address` AS 'address_out' |