[Solved] Can you help me to simplify codes OR in PHP

In answer to your question, no, you can’t use OR statements this way. What you can do is make $quantity conditionally based on the data you’ve got, for example: $price = !empty($item->unit_price) ? $item->unit_price : $item_kit->unit_price; $quantity = $fetch_barcode[‘item_price’] / $price solved Can you help me to simplify codes OR in PHP

[Solved] Get number from an url in PHP

With regexp: $str=”http:example.com/country/France/45″; preg_match(‘/http:example\.com\/country\/(?P<name>\w+)\/(?P<id>\d+)/’, $str, $matches); print_r($matches); // return array(“name”=>”France”, “id” => 45); 0 solved Get number from an url in PHP

[Solved] Inserting data into mySQL table from mutlidimensional input form

What I’m assuming is.. SomePage.php <input type=”text” name=”quantity[]”> <input type=”text” name=”description[]”> <input type=”text” name=”article[]”> <input type=”text” name=”price[]”> <input type=”text” name=”tax[]”> <input type=”text” name=”discount[]”> Submit_Some_Page.php <? extract($_POST); $TotalArticle=sizeof($article); for($i=0;$i<$TotalArticle;$i++) { $Article=$article[$i]; $Quanity=$quantity[$i]; $Price=$price[$i]; $Tax=$tax[$i]; $Discount=$discount[$i]; $Description=$description[$i]; <– Now, Write Insert Query Here.. $Query=”INSERT INTO TableName SET Col1Name=$Article,Col2Name=$Quanity,Col3Name=$Price,Col4Name=$Tax,Col5Name=$Discount,Col6Name=$Description”; ….. Write Mysql Query To Execute It } ?> … Read more

[Solved] PHP does not insert into mysql

I think you didn’t close out the Values with an end parentheses. $result = mysql_query( “INSERT INTO property( Pname, P_Price,P_Desc,P_City, P_Size,P_Rooms, P_garage, P_Address, P_Long, P_Lat, P_Sold, Provinces_idProvinces) VALUES(‘http://10.0.2.2/images/pic3.jpg’,98000,’beautifull house’,’Durban’,’7m’,1,2,’L-377 Umlazi’,’30.863226′,’-29.971518′,0,’1′)”); solved PHP does not insert into mysql

[Solved] What join should I use with MySQL? [closed]

There are a few small mistakes in your query. In the ‘From’ section you only need to use the first table, and you’ll need to tell the join which field from the first table matches which field in the second table. In the where you’ll only have to match one field to $savingsId This query … Read more

[Solved] What’s wrong with my button?

Make your button type as “submit” like below. <button type=”submit” name=”ubah” class=”btn btn-primary”>Ubah</button> Else you can also keep it as button, but in that case u need to use ajax(javascript) and onclick event on button , for example : <button type=”button” name=”ubah” class=”btn btn-primary” onclick=”save()”>Ubah</button> where save() is some function in javascript that you will … Read more

[Solved] How to divide items equally in 4 boxes? [closed]

Create a function that gets a product weight and returns a bag number – the one which has the least free space that’s still enough to fit. Put it in the bag. Repeat until done. $bags = array(60,80,20,10,80,100,90); $containers = array(1=>100,2=>100,3=>100,4=>100); // number -> free space $placement = array(); rsort($bags); // biggest first – usually … Read more

[Solved] how to convert for loop results in json

In your loop, create a new array occurance each iteration. Then use json_encode() to turn that array into a valid JSON string. $json = []; for ($i = 0; $i < (count($getnodays)); $i++) { $json[] = [‘Category’ => $getctgry[$i], ‘Priority’ => $getpriotity[$i], ‘NoOfDays’ => $getnodays[$i], ‘StDate’ => $date1[$i], ‘EdDate’ => $date2[$i], ]; } echo json_encode($json); … Read more