[Solved] website upload file to directory [closed]

Try this: <form id=”form_request_file” method=”post” action=”index.php” enctype=”multipart/form-data”> <table align=”center” width=”525″ border=”0″> <label for=”uploaded” class=”control-label col-sm-2″>Upload File</label> <input id=”uploaded” name=”uploaded” type=”file”/> <input value=”Submit” name=”submit” type=”submit”/> </form> <?php if (isset($_POST[‘submit’])) { if (isset($_FILES[‘uploaded’])) { $path = “uploaded_docs/”; $file_name = basename($_FILES[‘uploaded’][‘name’]); $target = $path . $file_name; if (move_uploaded_file($_FILES[“uploaded”][“tmp_name”], $target)) { echo $file_name . ” was uploaded”; } else … Read more

[Solved] How to get popular keywords in an array

array_count_values will output the count as like Array ( [keyword1] => 10 [keyword2] => 3 [keyword3] => 6 [keyword4] => 5 [keyword5] => 1 ) But For your desired output you need to use foreach Demo $arra = Array ( 0 => “keyword1”, 1 => “keyword1”, 2 => “keyword1”, 3 => “keyword1”, 4 => “keyword1”, … Read more

[Solved] How to Add background or change text

This really shouldn’t be done in jQuery, and you could still use a few lessons in being clear with what you’re looking for, but a question is a question, and here is my answer: $(‘th’).hide(); var $titlerow = $(‘tr td:first’), $yearrow = $(‘tr:eq(1) td:first’), title = $titlerow.text(), year = $yearrow.text(); $titlerow.text(title + ‘ – ‘ … Read more

[Solved] PHP syntax ?? meaning,can somebody explain? [duplicate]

It’s null coalesce operator. It will return $_GET[‘page’] unless it’s null. In case it’s null it would return default value ‘home’. It has same meaning as: !is_null($_GET[‘page’]) ? $_GET[‘page’] : ‘home’ 1 solved PHP syntax ?? meaning,can somebody explain? [duplicate]

[Solved] Preg_match on multiline text

The idea is to avoid the issue of new lines by not using the dot ($subject is your string): $pattern = ‘~ Project\hNo\.\h\d++\hDATE\h (?<date>\d{1,2}\/\d{1,2}\/\d{1,2}) \s++No\.\hQUESTION\hANSWER\s++ (?<No>\d++)\s++ # all characters but D or D not followed by “ate Required” (?<desc>(?>[^D]++|D(?!ate\hRequired))+) \D++ (?<date_required>\d{1,2}\/\d{1,2}\/\d{1,2}) ~x’; preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER); print_r($matches); Note that i use possessive quantifiers and atomic … Read more

[Solved] Web scraping photo in PHP

You can use regex to extract only background image or background:url format $str=” <div class=”thumb”> <a href=”http://goruzont.blogspot.com/2017/04/blog-post_6440.html” style=”background:url(https://1.bp.blogspot.com/-6vpIH5iqPYs/WPzlNdxsRpI/AAAAAAAAntU/d7U_Ch_6FiIPwosNL4tWwqBeXw8qwo2nACLcB/s1600/1424051.jpg) no-repeat center center;background-size:cover”> <span class=”thumb-overlay”></span></a> </div>”; preg_match_all(‘~\bbackground(-image)?\s*:(.*?)\(\s*(\’|”)?(?<image>.*?)\3?\s*\)~i’,$str,$matches); $images = $matches[‘image’]; foreach($images as $img){ echo $img; } # https://1.bp.blogspot.com/-6vpIH5iqPYs/WPzlNdxsRpI/AAAAAAAAntU/d7U_Ch_6FiIPwosNL4tWwqBeXw8qwo2nACLcB/s1600/1424051.jpg 3 solved Web scraping photo in PHP

[Solved] Writing php in a way that allows

Basically write it in HTML so I wont have to change the quotation marks every time Use HereDoc syntax then $html=<<<HTML <p style=”font-size:16px; color:red;”>Hello world!</p> <p> You don’t have to worry about single quotes ‘ or double quotes ” </p> HTML; 6 solved Writing php in a way that allows

[Solved] Rounding decimal number only last two digit PHP

$input=0.27777777777778; $number = number_format(round($input,1),2); echo $number; Round your number to 0.3, then use number format to show two decimal points. From the PHP manual / docs: Rounding numbers – Link Number format – Link 1 solved Rounding decimal number only last two digit PHP

[Solved] How can i Store HTML arrays into Mysql using PHP in each columns

<SCRIPT language=”javascript”> function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; if(rowCount < 10){ // limit the user from creating fields more than your limits var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i <colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[0].cells[i].innerHTML; } }else{ alert(“Maximum Number of Books is … Read more

[Solved] How to get data from ajax? [closed]

Data needs to be an object. Example: stop: function(){ $.ajax({ type: “POST”, data: {name: name, lastname: lastname}, url: “ajax.php”, }); } In case of form could be: data: $(‘#form’).serialize(); 0 solved How to get data from ajax? [closed]