[Solved] % (examples in loop) [closed]

[ad_1] One particular use is to check even / odd: for($i=0; $i<10; $i++) { if($i%2==0) echo “even” else echo “odd” } This idea could be used to color rows (tr) of a table differently for better presentation. Another use is to close TR dynamically in a complex code (lets say, change tr after every 4 … Read more

[Solved] Delete first array php

[ad_1] The only reason why you would get such an output is because you print_r inside the loop. I believe you have something like: $aa = [47, 51]; foreach($aa as $a){ $b[] = $a; print_r($b); } /*Output: Array ( [0] => 47 ) Array ( [0] => 47 [1] => 51 )*/ But instead you … Read more

[Solved] post route in Laravel

[ad_1] Try using url intead of route <form action=”{{ url(‘ImportUsersFile’) }}” method=”POST” enctype=”multipart/form-data”> <input type=”hidden” name=”_token” value=”{{ csrf_token() }}”> add users via excell<input name=”file” class=”form-control” style=”padding-bottom:3em; margin-bottom:3em” type=”file”> <div style=”display:inline;”> <input type=”submit” class=”btn btn-primary btn-lg” value=”ارفع” > </div> </form> And in your routes: Route::post(‘ImportUsersFile’, [‘uses’ => ‘ExcelUserController@importUser’, ‘as’ => ‘importUser’]); 2 [ad_2] solved post route … Read more

[Solved] You have an error in your SQL syntax…?

[ad_1] You will have to check if there is no starting and trailing comma’s in the $columns or $values variables. Plus, just to be sure, put appropriate quotes around the columns and values individually. public function insert($data, $table) { $columns = “”; $values = “”; foreach ($data as $column=>$value) { $columns .= “`” . $column … Read more

[Solved] How to remove query string from “href” attribute of anchor using php?

[ad_1] Use /\?[^\”]+/ like bellow: <?php $string = ‘<a href=”https://stackoverflow.com/title/tt3110958/?ref_=nm_flmg_act_2″ style=”color:#666″ >’; $result = preg_replace(“/\?[^\”]+/”, “”, $string); echo $result; ?> Output : <a href=”https://stackoverflow.com/title/tt3110958/” style=”color:#666″ > 0 [ad_2] solved How to remove query string from “href” attribute of anchor using php?

[Solved] How to automaticly update some thing after user pay with paypal [closed]

[ad_1] According to PayPal’s documentation, “When a customer makes a payment to you or a payment is reversed or refunded, PayPal will post a notification to your server at the URL you specified.” You provide them with the page, e.g. www.my-site.com/process.php, and payment should post. Handle that with if ($_POST[“payment”] != “”){ …your code to … Read more

[Solved] How to post form value to url and database using php [closed]

[ad_1] First of all, break your code up into sections and test each section. First, test that you have received the data correctly. A single error can stop the entire page from processing, so ensure you are receiving what you think you are receiving: $name = $_POST[‘name’]; $phone = $_POST[‘phone’]; $email = $_POST[’email’]; …etc… $zz … Read more

[Solved] MS SQL query not working on MySQL [closed]

[ad_1] SELECT ppmap_d.*, p_prob.*, ppmap_h.*, p_probgroup.*, p_prod.*, ppmap_d.prob_id AS probid, ppmap_d.map_id AS mapid, ppmap_h.pg_name AS probgname, ppmap_h.m_id AS modelid FROM p_prob INNER JOIN p_prod ON ppmap_d.prob_id = p_probgroup.prob_id INNER JOIN ppmap_h ON ppmap_h.map_id = ppmap_d.map_id AND ppmap_h.pg_name = p_probgroup.pg_name INNER JOIN ppmap_d ON p_prod.m_id = ppmap_h.m_id INNER JOIN p_probgroup ON p_prob.prob_id = p_probgroup.prob_id; 4 [ad_2] … Read more

[Solved] Undefined variable: __ROOT__ PHP 7? [duplicate]

[ad_1] $__ROOT__ seem’s to be your document root (writed as a “magic constant” variable.. and visibly, the transition to php7 broke… 🙂 often it’s defined by using real php magic constant like : For PHP >= 5.3.0 try __DIR__ For PHP < 5.3.0 try dirname(__FILE__) [ad_2] solved Undefined variable: __ROOT__ PHP 7? [duplicate]

[Solved] PHP script to update mySQL database

[ad_1] Your sql is wrong. Apart from the gaping wide open SQL injection attack vulnerability, you’re generating bad sql. e.g. consider submitting “Fred” as the first name: $First_Name2 = “Fred”; $query = “UPDATE people SET Fred = First_name WHERE ….”; now you’re telling the db to update a field name “Fred” to the value in … Read more

[Solved] Read var_dump data with PHP

[ad_1] You’ll want to read the var dump types to determine how to access the data structure. If it says object (e.g., in your dump it first lists object(stdClass)#13), then you’ll use -> operator to access the listed elements (e.g., $object->contact). If it says array, you can use index notation [0] or, if more than … Read more

[Solved] PDO table inside table using json

[ad_1] Start by returning objects from PDO as that is what you want. Then only select from the table the columns that you actually need Then build the data structure that you believe you want from the returned data $stmt1 = $db->prepare(“SELECT title,description FROM data WHERE id=’1′”); $stmt1->execute(); $data = $stmt1->fetch(PDO::FETCH_OBJ); $stmt2 = $db->prepare(“SELECT id,title … Read more