PHP - How Do I Print The Triangular Series Onto A File Using Php?
What im trying to do is create a file with the name "triangular_10.txt" where the number in the file name is the number the user entered. From there I want the text file to have the triangular series of numbers. So if the user enters 10, it'll display the first 10 numbers of the triangular series. So far the file name change is working. The algorithm is here that I used for PHP:http://www.codecodex.com/wiki/Calculate_a_triangle_number eg . user enters 10. Result in txt file is first 10 numbers in the triangular series = [1, 3, 6, 10, 15, 21, 28, 36, 45] This is what I have so far but Im not having any luck! At the moment its only writing the number I entered on to the txt file and nothing else! Any ideas? $number = $_POST['number-entered']; foreach ( range(1, 1000) as $i ) { $triangle_numbers[] = $i * ( $i + 1 ) / 2; } //make a file $contents = fopen('gs://a1-task22020.appspot.com/triangular_' .$number. ".txt", "w"); fwrite($contents, $number); //open the file $contents = fopen('gs://a1-task22020.appspot.com/' . $contents, 'w'); // re-open the document if you put something in it fwrite($contents, $number); fclose($contents); } }
Similar TutorialsAnyone know how I can print a file (specifically a PDF) that is stored on the server to the clients computer with a button? I don't want them to be able to view it, just print it. I've done some research and understand that there is no way to print directly without popping up the Windows Print dialog. And that is fine. I just want them to print this file, but not no where it is or be able to type in a URL to access it. Thanks Mike Hello guys and gals, I am pretty green to PHP! I have an empty array that that I am trying to put images into. The thing is I have a certain file name in the folder, I want to exclude that file. This is what I have tried, any advice would be appreciated! Code: [Select] $thumbImg[] = array(); foreach (glob($DImg) as $PImg) { if (!is_file("thumbnail.jpg")) { $thumbImg[] = "<img src=\"pathtoimage\">"; } } Later on the page I am printing it out with this. It is still including the thumbnail.jpg image. Thank you in advance!! Code: [Select] for ($i=0; $i<count($thumbImg); $i++) print $thumbImg[$i]; Hello, hi, whats the best way to print labels. I have already tried the script from fpdf.de but i can not get my dot matrix printer (dot matrix is needed for this purpose) the correct layout. Its continuous paper, with size 110 height x 62mm width (for each label). I am not able to select a self-adjustable paper-size. so i hope to solve this with PHP / PDF if possible. anyone have experience with this? cheerz!! is there a way to print the file as it appears. I want to print the HTML and PHP within a file rather than just the output. Example: File contains: <?php echo "Hello World"; ?> i would like to echo: <?php echo "Hello World"; ?> instead of just hello world which is what i get with file_get_contents() Hello, I have the following code writting IP,session, and date to a text file (it works) but I want to add a white space after the IP address. fwrite($fp, $_SERVER['REMOTE_ADDR']. $_SESSION["sess_name"]. " $dateTime\r\n"); At the moment it prints like this 16.17.51.41SESSION_ID 2011/01/23 12:53:32 thanks in advance. Hi everyone, I have a gateway and I can submit 200 max at one time using POST. I need to send around 200,000 at a time. So, in a nut shell, I need to submit 1,000 POST without actually refreshing my page. How can I do that ? Becuz once I submit a POST, the page on my browser goes to the gateway page rather than staying on the current page. So, what I need is something like click one button do 1,000 POST and send around 200,000. Looking forward to receiving any input on this. Thanks all. Regards I have a table that shows all the users in my table. Each user is either a user or an admin. I have radio buttons for each user determining if they are a user or an admin Right now I have each RB group named userlevel0, userlevel1, userlevel2 etc.. How can I get all the groups dynamically? I attempted an html array but failed. Hii,
I created a view with few selected data from table. I provided link to title to have redirection on editing page. I am passing variables to dynamic editing page. In editing page, I created a form which is filled automatically using id. Now on submission of updated form I redirected it to another php page for back-end processing. But now I am not getting data of inputs from editing page. POST and GET both are not working. I don't understand why is it not passing values.
Login ► View Data ► Select Data To Update ► Update Is not working here
Edited by Parth_Innovator, 05 December 2014 - 12:57 PM. I have a series of string which can have a value or empty. I want to display them with echo. echo $string1 $string2 $string3; satisfies my need, as it shows available values, but with this method, I will get a PHP notice in my error_logs. What is your suggestion? Do I need to use "if (empty)" or "if(isset)"? The point is I have numerous strings and in each run only few of them have value. I have a series of echo statements containing html and php elements. Is it possible to somehow store the following statements in one variable by concatenating and later print that variable. The variable should print out the statements as it is printing now. Code: [Select] <? echo "USER banned:<b>"; echo '<a style="text-decoration: none;" href="'.$forumurl.'1acpanel/user.php?do=edit&u='.$banuserid.'"<fontcolor="#4822aa" face="verdana" size="2">'.$banusername.'</font></a><br>'; echo "</b>USER Banned By:<b>"; echo '<a style="text-decoration: none;" href="'.$forumurl.'1acpanel/user.php?do=edit&u='.$banneruserid.'"><font color="#4822aa" face="verdana" size="2">'.$bannerusername.'</font></a><br>'; echo "</b>Banned on:<b>".$bandate."</b><br>"; echo "Reason:<b>".$reason."</b><br><br>"; ?> Image name will come from database. It can be displayed in divs or table cells. Which is better using divs or table cells? Can anyone post sample code? http://img28.imageshack.us/i/44233003.png/ I have some data where each has a timestamp when is was measured, and not all data points will be necessarily measured at the same time.
Time | Value1 | Value2 | Value3 | Value4 2020-12-15 00:05:07 | | 27.6 | | 2020-12-15 00:30:27 | | | 26 | 2020-12-15 01:20:10 | 53.9 | 25.2 | | 2020-12-15 02:09:44 | | 26.4 | | 60.2 2020-12-15 02:43:19 | 33 | 49.2 | | 2020-12-15 03:04:44 | 30.8 | | | 42 2020-12-15 03:21:46 | | 54 | | 2020-12-15 03:47:19 | 52.8 | | 53.3 | 2020-12-15 04:26:20 | | | 27.3 | 2020-12-15 04:45:10 | 37.4 | | | 2020-12-15 05:24:25 | | 42 | | 2020-12-15 05:34:49 | 36.3 | | 41.6 | 2020-12-15 05:36:04 | 24.2 | | | 2020-12-15 06:06:47 | 49.5 | | | 2020-12-15 07:00:07 | | | | 49 2020-12-15 07:59:17 | | 27.6 | | 2020-12-15 08:14:45 | | | 48.1 | 51.8 2020-12-15 08:26:36 | | | 53.3 | 2020-12-15 08:54:23 | 50.6 | | | 2020-12-15 09:46:53 | | | 58.5 | 43.4 2020-12-15 10:25:03 | | | | 36.4
I am trying to obtain the total value (i.e. value1 + value2 + value3 + value4) and since there is no common time interval, come up with an arbitrary one such as one hour. It doesn't need to be exact and one option is to linearize each sample between each of their individual timestamps, but ideally I can do a little better. It has been many, many years, and I recall that least squares regression used to be used for things like this, but I think I would need to the process the entire series for each which I expect would require many polynomials. I've never used R and it might be an option if necessary. Not sure if there is anything baked into PHP which would be great. Any ideas? Thanks Time |Total Value 2020-12-15 00:00:00 | 27.3 2020-12-15 01:00:00 | 48.4 2020-12-15 02:00:00 | 21 2020-12-15 03:00:00 | 22 2020-12-15 04:00:00 | 49 2020-12-15 05:00:00 | 38 2020-12-15 06:00:00 | 49 2020-12-15 07:00:00 | 29 2020-12-15 08:00:00 | 49 2020-12-15 09:00:00 | 46 2020-12-15 10:00:00 | 36
Hello, How to customize print page in php ? I had a page, but I need to print it like an invoice look page. Thanks in advance Hello.
i am totally new to php and just started to learn now. i just dont understand why the following code is not printing the username that i enter on the page.
Please note that the code itself is saved with the name "basicForm.php".
Thanks.
<html> Code: [Select] $query ="SELECT oneID FROM table WHERE table.PersonID = 'game.PlayerA'" ; $result = mysql_query($query); $row = mysql_fetch_array($result); $oneID = $row[0]; [code] If I then echo "$oneID" why does it not print anything? $result echos resource7 Hi, What is the best way to print the local date and time, my website have customers from 4 or 5 countries. Saudi - UTC+3 Dubai - UTC+4 India - UTC+5.30 how to print the local time for them Thanks, I am using function to insert into database. But the primary key is automatic and I used Quote $_SESSION['Tes_ID'] = mysql_insert_id(); to retrieve this. But now that I use function method. I am not sure how to retrieve the primary key on to the next page. Code: [Select] $value = modulesql($postVar1, $postVar2, $SessionVar1, $SessionVar2); $_SESSION['Tes_ID'] = mysql_insert_id(); echo $value, $_SESSION['Tes_ID']; Code: [Select] <?php function modulesql($Tes_Name, $Tes_Description, $Use_ID, $Sub_ID){ $con = OpenConnection(); mysql_select_db("examination", $con); $module = ("INSERT INTO test (`Tes_Name`, `Tes_Description`, `Use_ID`, `Sub_ID`) VALUES ($Tes_Name, $Tes_Description, $Use_ID, $Sub_ID)") or die('Cannot Execute:'. mysql_error()); CloseConnection($con); return $module; } ?> Have I lost you with my question?? print("<form name='form1' method='post' action='create-b.php' enctype='application/x-www-form-urlencoded' style='margin:0px'> <input type='hidden' name='time' value='werwRG/443gooa22a04c0c2d46c802cc7e3b262398852$glg/WE?F'> <input name='name' value='Anonymous' type='text' MAXLENGTH='15' style='position:absolute;width:650px;left:67px;top:142px;z-index:11'> <input name='subject' value='(No subject)' MAXLENGTH='15' type='text' style='position:absolute;width:650px;left:67px;top:166px;z-index:11'> <textarea name='body' MAXLENGTH='255' type='text' style='position:absolute;left:67px;top:191px;width:650px;height:98px;z-index:11'></textarea> <input name='submit' type='submit' value='Create thread' style='position:absolute;left:614px;top:291px;z-index:11'> <div id='captcha' style='position:absolute; overflow:hidden; left:10px; top:296px; z-index:10'> require_once('captc/recaptchalib.php'); $publickey = '*******************************************'; echo recaptcha_get_html($publickey); </form> </div>"); How can I make the highlighted text be read as PHP and not just text? It has to be in the form tags... before you reply saying you forgot the php tags, no i didn't. I can't use php tags inside php tags... |