Line break after several results from database [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am pulling out data from a table, but instead of breaking a line after each result(or set of results), I would like to break the line after 'x' amount of those results, so I don't get long pages.
How can this be done with PHP?

You haven't posted any code so your question is going to get marked as off-topic.
If you're trying to do line breaks every X number of iterations then just do it.
$i = 0;
while ($row1 = mysql_fetch_assoc($result1))
{
if ($i % 5==0) {echo '<div>Multiple of 5, line break here</div>';}
$i++;
}

You have to use a pagination. Use something like this http://stefangabos.ro/php-libraries/zebra-pagination/

Related

How to calculate factorials using recursion in PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I know this code to use in order to find the factorial of any number but what if we wanted it to do more and change up the code, so that it can calculate and print the factorials of number less that 100 recursively. How should this code be modified? Should i use for loop or some other technique?
Try this code, as suggested by LornaJane:
function factorial($number) {
if ($number < 2) {
return 1;
}
return ($number * factorial($number-1));
}

rotating list per refreshing page [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Lets say there are three rows of information that loads on a site, and on the site, you only want 1 of the 3 rows to load each time the page gets refreshed, so it probably should be sorted by random or something better. what is the best code for this?
Go for array_rand()
<?php
$arr=array("Offer 1","Offer 2","Offer 3");
$val=array_rand($arr,1);
echo $arr[$val];

Sum up array values [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is the array: http://www.stylechica.de/array.rtf (I can't copy it here)
I need to sum up ["PriceInformation"]["PriceInformation"]["PriceDetails"]["Price"] and allready tryed all kind of stuff like
foreach ($output["PriceInformation"]["PriceDetails"]["Price"] as $product)
echo array_sum($product);
but it just won't work. Any ideas?
Because $product refers to each iteration of $output["PriceInformation"]["PriceDetails"]["Price"], you can't sum the entire array like this. The best way to do it would be to add it to a variable as you go:
$your_sum = 0;
foreach($output as $value) {
$your_sum += $value['PriceInformation']['PriceDetails']['Price'];
}
echo 'Sum: ' . $your_sum;

Resource ID #2? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Why when it displays does it say Resource id #2?
All I am doing is fetching a simple number (0) out of a .txt file:
$num = fopen('qnum/qnum.txt', 'r');
echo $num;
You are not actually reading the file. You are only opening it and acquiring a reference to the file. You have to add more code (e.g. something along the lines of the answers to this question) to read the contents of the file.

Using for next loop step 50 php? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want steps for using for next loop.
On a vb or vb.net
for i=0 to 1000 STEP 50
....
next
How can I use this code in php?
You can use something like this:
for ($i = 0; $i <= 1000; $i += 50)
{
// Your code...
}
It is wise to read PHP for for more details.

Categories