[Solved] How to get serial numbers dynamically? [closed]

remember to increase the number for each row. <?php $serial_no = 1; foreach ($seats as $seat) { ?> <tr> <td> <?php echo $serial_no++; ?> </td> <td> other markup here </td> <tr> <?php } ?> 4 solved How to get serial numbers dynamically? [closed]

[Solved] Best way to round down in PHP

You can use floor to round down, and the modulo (%) operator to determine how many bottles are left. $bottles = 100; $bottles_per_case = 12; print “There are ” . floor($bottles / $bottles_per_case) . ” cases…”; print “With ” . ($bottles % $bottles_per_case) . ” bottles left over”; solved Best way to round down in … Read more

[Solved] How can I use an array in str_replace() function?

You can do that by passing an array as first argument: $res = str_replace(array(‘ ‘, ‘-‘, ‘,’), ”, $str); You can test it here at phpfiddle.org. str_replace() PHP’s function let you choose if the three parameters will be a single value or an array. 0 solved How can I use an array in str_replace() function?

[Solved] What are C++ arrays in PHP? [closed]

You could just use explode(“,”,$list_of_emails) and then loop over the resulting array of email addresses to do your sending. You could also probably do this in bash with cut and/or xargs. solved What are C++ arrays in PHP? [closed]

[Solved] h3 tag doesnt echo in foreach loop in php

Try this it will work : function news5($newsarray) { $str=””; foreach($newsarray as $value) { $str.= “<h3>”.$value[‘title’].”</h3>”; } return $str; } echo news5($newsarray); Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made. If you require … Read more

[Solved] What do you think that the error_reporting(1); instruction makes? [closed]

E_ERROR is defined as 1, so it’s the same as error_reporting(E_ERROR); So basically it tells PHP only to report fatal errors. As Skilldrick says, you should use named constants, as their defined values can and will change through newer versions of PHP. One well-known such example is E_ALL, which had the following values (from the … Read more

[Solved] Magento Programming: Importing manufacturers while checking for existing duplicates and get manu. ID

Just a quick and dirty script, but this should be what you are looking for… <?php error_reporting(E_ALL | E_STRICT); ini_set(‘display_errors’, 1); /* * Boostrap Magento */ $mageFilename=”../app/Mage.php”; require_once $mageFilename; Mage::setIsDeveloperMode(true); umask(0); $mageRunCode=””; $mageRunType=”store”; Mage::init($mageRunCode, $mageRunType); /* * Set up required data */ $newManufacturers = file(‘manufacturers.txt’, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES); $newManufacturers = array_unique($newManufacturers); $attribute = Mage::getModel(‘eav/entity_attribute’) ->loadByCode(‘catalog_product’, … Read more

[Solved] counter-intuitive behavior of isset()

This shouldn’t be at all surprising. Why it evaluates true when $foo is a string: $foo[‘name’] is the same thing as asking for the zeroeth character of $foo when it’s a string – because ‘name’ or ‘camel’ or ‘cigar’ or ‘any other string’ will be coerced into an integral value in that context. array_key_exists() might … Read more

[Solved] Program that counts even digits in given number, but eats the first digit, and sometimes not. How to fix?

result.php <html> <meta charset=”UTF-8″> <body> <?php $input = $_REQUEST[“Input”]; $count = 0; for ($i = 0; $i < $input; $i++) { $x = $input % 10; if ($x % 2 == 0) { $count++; } $input = (int)($input / 10); } ?> Числото <?php echo $_POST[“Input”]; ?> съдържа <?php echo $count ?> четни цифри. </body> … Read more

[Solved] How to show all DB result with PDO

The answer is as follows: <?php $sql = “SELECT * FROM database WHERE id BETWEEN 1 AND 5″; $stmt = $conn->query($sql); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_OBJ)){ ?> <tr> <td><b><?php echo $row->hours ?></b></td> <td><a href=”#”></a></td> <td id=”dayhour-1″> <input type=”text” class=”form-control” id=”1″ value=”<?php echo $row->username ?>”> </td> </tr> <?php } ?> This code will do it’s work. Its … Read more

[Solved] use php in html file [closed]

html does not have variables by itself. In order to save data you will need a programming language like PHP or GAE with Python for example. You can either save the data into a database or into a simple file using php. You can then load the data from the file into a table with … Read more