PHP - Help Wiht Simple Print Function
Ok so its been a while since school and ive forgotton most my php as Ive been more into site building wiht css, html and graphics...
<?php $part=part(""); $size=size(""); $qty=qty(""); if (($part=="2") && ($size=="11") && ($qty=="100")) echo "Price quote is $59.00" else if (($part=="2") && ($size=="11") && ($qty=="500")) echo "Price quote is $99.00" ?> my goal is to have a simple form, wiht 3 drop downs qty, size, part are the field names. And depending what options they pick they get a price out put... im missing something so simple, I know it should only take a couple lines of code and simply repeat it wiht else if until you hit the end of all possible options. Can some one please help? Thanks Similar TutorialsOk so here's what I'm trying to do and what I'm having to do since I can not figure out how to script this.
I create my GUI for scripting in HTML. When I script I create a full HTML page for my input forms, one full HTML page for the error code and lastly one HTML page for the receipt when the script runs correct. I then create my php scripting (basic template where I can cut and paste my HTML for the GUI output once it has been encapsulated in FULL be the php print function after having the quotation marks escaped and replaced by a backslash follow by a quotation mark).
Currently and over the past Decade. I have done this encapsulation the Hard way. Meaning I build my HTML file in FrontPage. I save the HTML file and then I open it in Microsoft Notepad. First thing I do is use the replace All function from the edit menu to Find every instance of " and replace them all with \" then I manually goto the first line of code and place a Tad then type print " I then hold control and shift to copy the ( tab print ") and begin to paste manually using Ctrl V and then I hit the down arrow on my keyboard quickly followed by the Home button to drop my cursor down a line and input the beginning of my PHP print function encapsulation one frigging line at a time. Once I've reach the very bottom, I go up the back right hand side of the HTML document with my ending quotation followed by semi colon manually with Ctrl V and hitting up arrow followed by end button.
This process of encapsulation the hard way with note pad takes up 90% of my dev time when programming. It makes stuff easy to read in my code and is perfect for outputting. What I would like to do is find a way to create a php script with a file upload form field that would take the input of any and all html files and parse the full document automating the exact process that I run on all of my HTML GUI files so that I can turn the encapsulation work into nothing and focus on the actual scripting.
You wouldn't believe how many hours of Ctrl V and up n down end and home I have pressed. Spent 8 hours last night alone. When form fields have multiple drop down selectors for country code ect. the HTML files to encapsulate manually become Ridiculously long.
I have never seen or heard of anyone doing exactly what I've explained here as I know the print function used like this is not normal. Every HTML file or snippet in any of my scripting is always encapsulated in the print function to output. And I have no intentions on changing my style. I would like to automate my process. And if it is too complex for me to build it in a decent amount of time I am willing to pay good money to get this finished for me ASAP.
Please message me back ASAP as I'm working on a personal project that has over 2,000 HTML files for me to encapsulate a the minimum.
~PJ
I set up a form that you can type html code into. When you click submit it sends the form data to a php script that receives the data and then prints it. Basically im trying to accomplish something similar to this http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro. I have tried to print the html code using echo and print_r. The problem is that it is not displaying correctly. For instance if i were to type in Code: [Select] <body bgcolor="FFCC00"> Nothing would happen. Most of the html displays correctly. What is the reason behind this? Do i need to use a different command to print the form variable? Or do i need to save it as an html document then display it? Dear all, Kindly help with this code I have written, it is not returning the array I created. It is a very small script but I have been looking for a very long time but I couldn't see why it went wrong. $duration = 2; $start='01-01-2019'; $month =date('n', strtotime($start)); $year =date('Y', strtotime($start)); $mon = 12-$month+1; $remainingMonth = $duration*12; $years_arr = array("$year"); $residue_arr = array("$remainingMonth"); $years_arr = process($remainingMonth,$year,$mon,$years_arr,$residue_arr); print_r($years_arr); //<output function process($remainingMonth,$year,$mon,$years_arr,$residue_arr){ $residue = $remainingMonth - $mon;//$D$18-D20 if($residue != 0){ $new_year = $year+1; array_push($years_arr, $new_year); array_push($residue_arr, $residue); if($residue > 12 ){ $mon = 12; } else { $mon = $residue; } echo "<br>"; process($residue,$new_year,$mon,$years_arr,$residue_arr); } else { print_r($years_arr); return $years_arr; } }//end of process(..) The objective is to add a year to the $years_arr array and then print it put, yet I notice that nothing get's printed out. Please assist, if you need more info from my side, please do ask. Thank you very much in advance. Ok people I'm trying to write a simple function that will pass a blank string back to my form when the clear button is clicked, but for some reason it will not clear my form. I can't figure this out I have written other functions that have worked, but for some reason this has me stumped. Here is my function Code: [Select] //function to clear variables function clearVars(&$j, &$k) { $workValue = ""; $workType = ""; } Code: [Select] $workValue = (isset($_POST['vfld']))?$_POST['vfld']:''; $workType = (isset($_POST['tfld']))?$_POST['tfld']:''; if (isset($_POST['submit'])) { if ($_POST['submit'] == "Clear") { clearVars($vfld,$tfld); } elseif ($_POST['submit'] == "Calculate") { getVars($vfld,$tfld,$calc); $continue = testVars(); if ($continue == "yes") { switch ($workType) { case "circle": calcCircle($workValue); break; case "square": calcSquare($workValue); break; case "triangle": calcTriangle($workValue); break; } } } } ?> <form method="post" action="hw06.php" id="form1" name="form1"> <p> Enter a number here : <input type="text" id="vfld" name="vfld" value="<?php echo $workValue; ?>"/> </p> <p> This number is: <br /> <input type="radio" name="tfld" value="circle" <?php if ($workType == "circle") { echo 'checked="checked"'; } ?> /> : the radius of a circle <br /> <input type="radio" name="tfld" value="square" <?php if ($workType == "square") { echo 'checked="checked"'; } ?> /> : the length of one side of a square <br /> <input type="radio" name="tfld" value="triangle" <?php if ($workType == "triangle") { echo 'checked="checked"'; } ?> /> : the length of one side of an equilateral triangle </p> <p> <input type="submit" name="submit" value="Calculate" /> <input type="submit" name="submit" value="Clear" /> </p> </form> <div id="footer"> <pre>This page written by: <cite>The President</cite> ©2011 and beyond</pre> </div> </body> </html> Hello I am trying to create a simple update function. but it is giving me syntax error. May you please review my code The function call: function update_article_stats ($article_num) The Function Declaration in the functions.php function update_article_stats ($article_num) { $query = "UPDATE `articles_content` SET `cnt` = cnt+1 WHERE `num` = '$article_num' "; $result = mysql_query($query); } Thank you so much This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=344481.0 Code: [Select] function display_details($name, $department="sales", $sex="male") { return "You are {$name} from {$department} and you are {$sex}"; } I need to use the default value for $department, but none of the below work. How do I do it? echo $display_details("Sally", NULL, "female"); // sets $department as empty/blank echo $display_details("Sally", "", "female"); // sets $department as empty/blank echo $display_details("Sally", , "female"); // PHP error but never on the first call. Okay, I posted this on StackOverflow but no one there seems to have an answer either. I have this simple function: Code: [Select] public function delete($messageID) { $type = $this->findType($messageID); if ($type == 'in') { foreach ($this->inArr as $key => $value) { if ($this->inArr[$key]->messageID != $messageID) $implodeData[$key] = $this->inArr[$key]->messageID; } if (!isset($implodeData)) $imploded = '0'; else $imploded = implode(',', $implodeData); $result = $this->_database->updatePMUser('inArr', $imploded, 'UID', $this->UID); $result2 = $this->_database->deletePM('messageID', $messageID); return; } else { foreach ($this->sentArr as $key => $value) { if ($this->sentArr[$key]->messageID != $messageID) $implodeData[$key] = $this->sentArr[$key]->messageID; } if (!isset($implodeData)) $imploded = '0'; else $imploded = implode(',', $implodeData); $result = $this->_database->updatePMUser('sentArr', $imploded, 'UID', $this->UID); $result2 = $this->_database->deletePM('messageID', $messageID); return; } } It is a delete function for a private messaging program for a forum script I'm writing. Anyway, here's the issue - it works! But only sometimes. It is called in 3 different places, always from a form processing class I have, once in the view message section to delete a message you're viewing, in a foreach from the sentbox options section and then a foreach in the inbox options section. The inbox and sentbox option sections do that whole "delete the checked messages" for the mass removal functionality. The delete function above works in all ways shapes and forms when I use it in single calls - like when I'm deleting a message while viewing it or when I only check one message from the inbox, etc - but when I call it multiple times (as in I have checked multiple messages) - it fully deletes one (both the message and the reference to the message in the user's db row) and then only deletes the actual message on the others (deleting the message is the call to deletePM - deleting the reference is the call to updatePMUser). Okay, if you need further information - the function above checks the type the message is (in the inbox or in the sentbox) and then uses that to foreach through that array (inArr or sentArr) of the user. It logs in all the messageIDs of the those that DON'T match the one we're deleting and then at the end it implodes those caught IDs into a string that is then updated in the user's row as a comma separated string of values each representing a message in the DB - you get the picture. I realize I have some trimming to do (for one I can cut the above function down by about half by using variable variables) but I'll get to that after I get the thing working. I can't figure out why it's doing what it's doing. If you need the function that calls this in the foreach, I have it below. Oh, and the thing that really boggles me is that this function is called fully for each checked message in the foreach - it fully returns and then loops - if it works once, I don't see how it wouldn't work on a second call from a loop - the variables it uses should be trashed when it leaves the function, they aren't global or object properties or anything. Color me confused. Thanks for any help, oh, here's one of the functions that calls it to delete checked messages (this one is for the sentbox, there is another for the inbox): Code: [Select] private function _processSelectedSent() { $pmObj = unserialize(base64_decode($_POST['pmObj'])); $i=1; foreach ($_POST as $key => $value) { if ($value == 'marked') { $checkedArray[$i] = $key; $i++; } } if ($_POST['submitter'] == 'Delete Selected') { if (is_array($checkedArray)) { foreach ($checkedArray as $key => $value) $pmObj->delete($value); } else $pmObj->delete($checkedArray[1]); header("Location: ".HOME_PAGE.PM_PAGE."?view=sentbox&nocache=".time()); } } Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); Hi everyone, I'm trying to select either a class or an id using PHP Simple HTML DOM Parser with absolutely no luck. My example is very simple and seems to comply to the examples given in the manual(http://simplehtmldom.sourceforge.net/manual.htm) but it just wont work, it's driving me up the wall. Here is my example: http://schulnetz.nibis.de/db/schulen/schule.php?schulnr=94468&lschb= I think the HTML is invalid: i cannot parse it. Well i need more examples - probly i have overseen something! If anybody has a working example of Simple-html-dom-parser...i would be happy. The examples on the developersite are not very helpful. your dilbertone Hello, im very green to php and I am having trouble creating a simple log in script. Not sure why this is not working, maybe a mysql_query mistake? I am not receiving any errors but nothing gets updated in the members table and my error message to the user displays. any help is appreciated! here is my php: <?php session_start(); $errorMsg = ''; $email = ''; $pass = ''; if (isset($_POST['email'])) { $email = ($_POST['email']); $pass = ($_POST['password']); $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); if ((!$email) || (!$pass)) { $errorMsg = '<font color="#FF0000">Please fill in both fields</font>'; }else { include 'scripts/connect_db.php'; $email = mysql_real_escape_string ($email); $pass = md5($pass); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass'"); $log_check = mysql_num_rows($sql); if ($log_check > 0) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $_SESSION['id']; $email = $row["email"]; $_SESSION['email']; $username = $row["username"]; $_session['username']; mysql_query("UPDATE members SET last_logged=now() WHERE id='$id' LIMIT 1"); }//Close while loop echo "You are logged in"; exit(); } else { $errorMsg = '<font color="#FF0000">Incorrect login data, please try again</font>'; } } } ?> and the form: <?php echo $errorMsg; ?> <form action="log_in.php" method="post"> Email:<br /> <input name="email" type="text" /><br /><br /> Password:<br /> <input name="password" type="password" /><br /><br /> <input name="myBtn" type="submit" value="Log In" /> </form> 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> 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 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 can someone pls help, im tryin a tutorial but keep getting errors, this is the first one i get after registering. You Are Registered And Can Now Login Warning: Cannot modify header information - headers already sent by (output started at /home/aretheyh/public_html/nealeweb.com/regcheck.php:43) in /home/aretheyh/public_html/nealeweb.com/regcheck.php on line 46 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 trying to get the code at the bottom of the script to print just once during the loop but it either doesn't print at all or repeats with the loop im am using if (!$i++) to print once and i works the first time i use it. foreach($uploadFilename as $key => $myvar) { if (!$i++) print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Upload Complete....</title> </head> <body> <body onload=\"document.forms.formname.submit);\"> <form id=\"formname\" name=\"form1\" method=\"post\" action=\"reg5.php\">\n"; echo "<input type=\"hidden\" name=\"image$key\" value=\""; echo end(explode('/',$myvar)); echo "\">\n"; if (!$i++) print "</form> </body> </html>\n"; } Is there a way to dynamically print the url of a web page once it loads? If so, how? This is for metadata purposes. Thanks! Hi I have this code to echo th econtents of a table, which contains 100 rows. I want to be able to display all 100 rows. The problem is that it displays 99 (it excludes the first). I've tried to backtrack to reconstruct the code to find out where the error is but no joy. Any ideas? Thanks in advance! Code: [Select] .... // get all entries from table $sql = "SELECT * FROM 100words ORDER BY word_id"; $result = mysqli_query($dbc, $sql); $r = mysqli_fetch_row($result); //print table entries to screen in columns echo '<div id="container">'; // results presented in html table 5 columns, 20 rows per page echo '<div id="outerbox">'; echo '<div class="innerbox">'; echo '<table class="centerresults" border="0">' . "\n"; echo '<td>'; $i = 0; $max_columns = 5; while ($list = mysqli_fetch_assoc($result)) { extract($list); // open row if counter is zero if($i == 0) echo '<tr>' . "\n"; echo '<td width="150px"><a href="word.php?w=' . $list['word'] . '">' . $list['word'] . "</a></td> \n "; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo '</td>' . "\n"; $i=0; } // END if(++$i == $max_columns) { } // END while (!empty($myArray)) { //} END while ($list = mysql_fetch_array($result)) { //END if($i < $max_columns) { echo '</tr>' . "\n"; echo '</table>' . "\n"; echo '</div>'; echo '</div>'; |