PHP - Create New Line Of Dynamically Populated Content From Button
Hi, I have a table row that has a dropdown and two textboxes in it. I would like to use a button that allows me to add another row beneath the existing row. It cannot be added to the bottom of the table as there is further content beneath. The content of the dropdown comes from a database query. The dropdown on the new row should have the selection in the first row greyed out. I expect this will need to be a js function but i dont really know where to start with it being dynamic content. This is the table as it stands if this provides clarity of my intentions - picture below echo "<form method='post' id='staffOrderForm'>"; $stmt->close(); echo "<table id='staffOrderTable' class='table table-striped table-bordered mt-3 text-center'>"; foreach($daterange as $date){ echo" <tr> <th class='table-dark' colspan='3'>".$date->format("l - jS F Y")."</th> </tr> <tr> <th class='' colspan='3'>Management </th> </tr> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select managerSelect'>"; $managerRoleId = 1; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $managerRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr> <tr> <th colspan='3'>Chefs</th> <tr/> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select chefSelect'>"; $chefRoleId = 2; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $chefRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr>"; } echo "</table></form>"; I appreciate that i will likely have to add a button with an onclick but from there i am pretty lost. As always i appreciate the help provided. Similar TutorialsFriends, I have a PHP script that populates a calendar based on an array as follows: $days = array(2=>array('javascript:showWhatsOnText(2);','linked-day'), 3=>array('javascript:showWhatsOnText(3);','linked-day'), 4=>array('javascript:showWhatsOnText(4);','linked-day')); echo generate_calendar(2011, 4, $days, 1, '#'); where, for instance, the 2, 3 4 are the days of the month, By extracting a series values from a MySQL database how would I generate this array dynamically. E.g I have startday, startmonth, name and text fields in the database and would need to loop through them all to create the array. I tried playing around with something like this without any luck: $queryCat1 = "SELECT * FROM $dbCalendarEvents ORDER BY id ASC"; // WHERE visible = '1' $result1 = mysql_query($queryCat1) or die (mysql_error()); $num1 = mysql_num_rows($result1); $i=0; $daysArray = array(); while ($i < $num1) { $startday=mysql_result($result1,$i,"startday"); $startmonth=mysql_result($result1,$i,"startmonth"); $name=mysql_result($result1,$i,"name"); $name=mysql_result($result1,$i,"name"); $copy=mysql_result($result1,$i,"copy"); $daysArray[$i] = $startday=>array('/weblog/archive/2004/Jan/02','linked-day'); $i++; } Your help is appreciated. We recently migrated over to a new AMP platform that I built from source and now we can't dynamically generate images. It seems like GD is properly included into PHP (although I didn't know then I could do it using dynamic modules): My PHP configure is as follows: ================================================== './configure' '--prefix=/export/appl/pkgs/php/v5.3.9' '--with-apxs2=/export/appl/pkgs/httpd/latest/bin/apxs' '--with-mysql=/export/appl/pkgs/mysql/latest' '--with-mysqli=/export/appl/pkgs/mysql/latest/bin/mysql_config' '--with-gd=/export/appl/pkgs/libgd/latest' '--with-pear' '--with-png-dir=/export/appl/pkgs/libpng/latest' '--with-jpeg-dir=/export/appl/pkgs/jpeg/latest' '--with-curl=/export/appl/pkgs/curl/latest' '--with-freetype-dir=/export/appl/pkgs/freetype/latest' '--with-mhash=/export/appl/pkgs/mhash/latest' '--with-mcrypt=/export/appl/pkgs/libmcrypt/latest' '--enable-pcntl' '--enable-soap' '--enable-mbstring' '--with-zlib-dir=/export/appl/zlib/v1.2.5' '--with-ldap' ================================================== The GD section in phpinfo is as follows: ================================================== GD Support enabled GD Version 2.0 FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.4.6 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version unknown PNG Support enabled libPNG Version 1.5.5 WBMP Support enabled Directive Local Value Master Value gd.jpeg_ignore_warning 0 0 ================================================== I get broken image icons in IE and Chrome, and I get an "image cannot be displayed" msg in FF. I'd appreciate someone clubbing me with a cluestick. - Joe I have a slideshow that I am having to modify for my needs. The data file uses an array and i need this to be dynamic. I need to loop through all images in a directory and create the array. I have the directory being stored in a variable already. Now i just need to loop though all images in that directory to create the array like you see in the below code. You can also see the directory variable at the top. Can someone give me a hand with this please? Code: [Select] <?php echo $slideimagefolder; //http://localhost:82/images/groupphotos/1/1/ $slides = array( // --- Start slide list --- // slide elements array( "slidelink" => "http://www.frontpageslideshow.net", "title" => "Frontpage Slideshow 1.7", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"Shoot 'em up\"", "text" => "\"Frontpage SlideShow\" is the most eye-catching way to display your featured articles, stories or even products in your php based website or CMS, like Time.com, Joost.com or Yahoo! Movies do. \"Frontpage SlideShow\" creates an uber-cool slideshow with text snippets laying on top of images. These \"slides\" are being rotated one after the other with a nice fade effect. The slideshow features navigation and play/pause buttons, so the visitor has complete control over the slideshow's \"playback\"! And best of all, Frontpage Slideshow can be skinned!", "slideimage" => "ao4.jpg" ), // slide elements array( "slidelink" => "http://www.frontpageslideshow.net", "title" => "Use Frontpage Slideshow on any PHP based site!", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"The Kingdom\"", "text" => "JoomlaWorks has developed this modification of Frontpage Slideshow to work on every website that supports PHP as a minimum requirement. We call this modification the \"Static PHP\" version of Frontpage Slideshow. It's ideal for use on non-Joomla!/Mambo websites, like for example your corporate PHP based website or your Wordpress blog or Drupal website! You can obviously use this version on any CMS that is based on PHP!", "slideimage" => "the_kingdom_20070820114258369.jpg" ), // slide elements array( "slidelink" => "http://www.frontpageslideshow.net/content/view/14/37/", "title" => "FPSS is Search Engine Friendly!", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"Invaders\"", "text" => "Unlike Flash based slideshows, Frontpage Slideshow uses unobtrusive javascript and some CSS wizardry only. The content of the slides is laid out as html code, which means it can be \"read\" by search engines. The proper usage (and order) of h1, h2, p (and more) tags will make sure Google (or any other search engine) regularly \"scans\" your latest/featured items.", "slideimage" => "TVD_TR_02183_2.jpg" ), // slide elements (***TIP***: copy this data block and paste it below itself to add more slides) array( "slidelink" => "http://www.joomlaworks.gr", "title" => "About JoomlaWorks", "category" => "", "tagline" => "Image taken from the movie \"Transformers\"", "text" => "JoomlaWorks is a team of professional web designers and developers dedicated to delivering high-quality extensions and templates for Joomla! (the most popular open source Content Management System (CMS) worldwide) and Mambo (award winning CMS). JoomlaWorks has established a solid reputation in the Joomla! & Mambo communities, having developed some of the most popular and innovative free & commercial extensions & templates, since 2006.", "slideimage" => "2007_transformers_014_1.jpg" ), // --- End slide list --- ); ?> Hi guys i have to create text field & enter data and store in the data base. here im able to create text field but couldn't insert the data. so could anyone please check this code for me. <body> <form method="POST" action="cell.php"> Enter the number of question <input type="text" name="question"> <input type="submit"> <?php $value=$_POST['question']; for($i=0;$i<$value;$i++) { echo "Question NO:"; echo '<input type="text" name="qno">'."\t"; echo "Enter Marks:"; echo '<input type="text" name="marks">'."\t"; echo "<br>"; } ?> </form> <form name="form1" method="post" action="cellresult.php"> <label> <input type="submit" name="Submit" value="Submit"> </label> </form> </body> cellresult.php <body> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $sql="INSERT INTO cell (QNO,MARKS) VALUES ('$_POST[qno]','$_POST[marks]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> </body> Hi, I want to create a .html file dynamically on the server. Below is the code for that but i was not able to create the file. I have given all the read, write and execute permission on the folder. $filerand = rand(); $fileName = "test.html"; $filepath = $_SERVER['DOCUMENT_ROOT'] . "\\testfolder\\" . $fileName . ".html"; echo $filepath; $bodytxt = "Welcome to my webpage"; $ourFileHandle = fopen($filepath, 'w') or die("can't open file"); fwrite($ourFileHandle, $bodytxt); fclose($ourFileHandle); Thanks in advance Hi, i coded a very simple forum "website" with registration, login, and a place where everyone posts comments. I wanted to make some sort of profile page for each user so they would each have their own URL too (e.i. test/barney or test/simpsons). each of these pages would have different content, depending on what barney or simpsons puts on that page. i've been looking everywhere trying to find documentation but i don't think i know how to search it correctly. I checked a lot of mod_rewrite documentation but i don't understand if i'm suppose to call a php function to create a profile page or something. Any guidance would be greatly appreciated Thanks! Hi, This problem has been driving me crazy all day. I am relatively new to PHP. I basically am trying to populate a database with data from site users. I am using session variables to store their data temporarily as they navigate through the sign up process. A user will input how many 'categories' they wish to populate on page 1. Page 2 will then ask them to specify the details of each category. Eg Category 1: Title, Description, Amount. Category 2: Title, etc. So far I have been able to do this, I now want to store what they have input in session variables. My thoughts were to take the number of categories they have sepcified and create that number of arrays using a loop. Each array will store the details on each category. My code is as follows: Code: [Select] $count=$_POST['count']; //Get how many categories were added //Create an array for each category for ( $counter = 0; $counter <= $count; $counter++){ ${'Categoryarr'.$counter} = array(); }; for ( $counter = 0; $counter <= $count; $counter++){ $Categoryarr[$counter][1]=$_POST['amount_'.$count]; $Categoryarr[$counter][2]=$_POST['desc_'.$count]; $Categoryarr[$counter][3]=$_POST['title_'.$count]; }; When I output the code, I seems to have created the specified number of arrays, but has populated all of them with the same data from the last category. Does anyone know where I am going wrong? Thanks, Bernard How to create a pdf dynamically and that pdf should sent as a email attachment.
hey i am using a MySql database and i need to create a dynamic HTML table with one of its columns as checkboxes.so i have to create multiple checkboxes.but these checkbox values are to be stored in a mysql table and then later retrieved when form reloads.and depending on previous state when form was submitted, the newly created checkboxes have to be checked in the same manner.so how do i store multiple checkbox values in my table and also how do i retrieve them? please help. Hello everyone, I am working on a form that is similar to a shopping cart system and I am thinking of creating a button that submits the checked value and saves them to a $_SESSION variable. And also a link that links to a cart.html that takes the values of a $_SESSION variable. I am have trouble figuring what tag/attribute should I use in order to achieve that.
Right now my code attached below submits the checked values to cart.html directly. However I want my submit button to save the checked box to a $_SESSION variable and STAY on the same page. And then I will implement a <a> to link to the cart.php.
I researched a little bit about this subject and I know it's somewhat related to ajax/jquery. I just wanted to know more about it from you guys. I appreciate your attention for reading the post and Thanks!
Below is the form that I currently have:
<form name= "finalForm" method="POST" action="cart.php"> <input type="Submit" name="finalSelected"/> <?php foreach($FinalName as $key => $item) {?> <tr> <td><input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td> </tr> <?php } ;?>Below is the code for cart.php <?php require ('connect_db.php'); if(isset($_POST['finalSelected'])) { if(!empty($_POST['fSelected'])) { $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "aID selected: $item </br>"; $delimit = implode(", ", $chosen); print_r($delimit); } } if(isset($delimit)) { $cartSQL = "SELECT * from article where aID in ($delimit)"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } ?> <table> <?php if(isset($delimit)) { $c=0; foreach($aTitle as $item) {?> <tr> <td> <?php echo $aTitle[$c]; $c++;?> </td> </tr> <?php }}?> </table> Hi, I have some files stored in mysql db. I have created a web page which shows the list of tutorials from db. at first i was creating a separate php page for each tutorial, but later i have decided that it would be easier and simpler if i can create one php page and whenever i click the tutorials it will change the content of this page. example: when i click "tut002" from list. it will change the content of tutorials.php . I have these tutorials in .html format here is the code i have in turorials.php once again, whenever i click a tutorial this include part needs to change automatically to whatever i click Code: [Select] echo '<div class="content">'; include ("inc/tut001.html"); echo '</div>'; it will be really appreciated if you have a sample code for this. sorry for my english. thank to whoever interested in this matter. Hi! So I have got some code that looks like this: Code: [Select] if (isset($_GET['view_log'])) { // show content (text from db) } When I click the button named "view_log" everything displays just fine, however I would like to be able to click the button again and make the content disappear. Is this possible using only PHP?? Thanks for the help!:) It is greatly appreciated! I have a site that I have an about page with pictures of people on it. I would like to create something that would do the following: * When you click on one of the images, i need text for that image to load in a text area. I would like to do this rather than have to make a different HTML page for each person, but I am not sure how to go about doing it. I do not have a database for this site, so I will need to pull the text from a text file or something like that. Any ideas on how to get started would be helpful. Thanks in advance! In this report I want to create a line break and a Total line for each State.
while ($row = odbc_fetch_array($result)) { echo "<tr><td>" . $row['cmlstate']."</td>"; echo "<td>" . $row['cmlpostcode']."</td>"; echo "<td>" . $row['cmlcity']."</td>"; echo "<td>" . $row['ompSalesOrderID']."</td>"; echo "<td>" . $row['cmoName']."</td>"; echo "<td>" . number_format($row['UOMPVOLUMETOTAL'],2)."</td>"; echo "<td>" . number_format($row['UOMPTOTALBOXCOUNT'],0)."</td>"; echo "<td>" . $row['Hold']."</td></tr>"; I want to sum 'UOMPVOLUMETOTAL' for each state and create a line break between it and the next state. }
I want to offer my site visitors the opportunity to use some of my content on their sites. For example, a Quote of the Day or This Date in History snippet that they can place on their site. I want to host and manage the content on my site and allow the visitors to syndicate it on their sites easily. The key word here is "easily". I don't want to do this through RSS, which can be tricky for entry-level webmasters and bloggers. I want to be able to offer a line of code, say in Javascript, that the visitor can copy and paste into their site (Wordpress widget etc.) and have my content appear there. Does anyone have any starting points for how to do this? I have several years of experience with PHPP, MySQL, CSS, HTML, etc., but I don't want to re-invent the wheel. I've done something similar in JSP, but not using PHP. I got a question regarding a news website content that i want to make ! my question is how do i call my contents without using a lot of page? i explain let's say i got 10 news how do i put this 10 news in different pages without using 10 pages ? ex: you can see some links having a number like this http://bbc.uk/news/murder_case-12 then the next page got http://bbc.uk/news/finance-13 the title and the number id change but the page news doesnt change thanks for your answer. I've been working on developing a CMS blog and now I'm trying to create a slideshow wit Bootstrap Carousel on the homepage to present the dynamic content (images + text) using the data from table 'posts'. I tested this code, and it only presents one post. I mean, It's not possible to go to the next slide. I want to show all the posts on the slides. *The DB connection is already on the includes. The connection was written on a small file called DB.php Home.php <header> <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li> <li data-target="#carouselExampleIndicators" data-slide-to="1"></li> <li data-target="#carouselExampleIndicators" data-slide-to="2"></li> </ol> <div class="carousel-inner" role="listbox"> <?php // The default SQL query $sql = "SELECT * FROM posts ORDER BY id desc"; $stmt = $ConnectingDB->query($sql); while ($DataRows = $stmt->fetch()) { $Id = $DataRows["id"]; $PostTitle = $DataRows["title"]; $Image = $DataRows["image"]; $PostText = $DataRows["post"]; ?> <!-- Slide --> <div class="carousel-item active" style="background-image: url('uploads/<?php echo $Image; ?>')"> <div class="carousel-caption"> <div class="card-body black"> <h3 class="large-mistral-white"><?php echo $PostTitle; ?></h3> <p class="small-times-white"><?php echo $PostText; ?></p> </div> </div> </div> <?php } ?> </div> <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </header> DB.php <?php $DSN='mysql:host = localhost; dbname=everybody_blog'; $ConnectingDB = new PDO($DSN,'root',''); ?>
i have a form per row with an update button my problem is to update each row at a time so i created a unique update button per row, not working Code: [Select] <table cellspacing="0" cellpadding="0" border="1"> <col width="75" span="5" /> <tr> <td width="75">Proposal</td> <td width="75"> </td> <td width="75">Supplier</td> <td width="75">Downpayment</td> <td width="75">Payment Method</td> <td width="75">Status</td> <td width="75"> </td> </tr> <?php do { ?> <tr><form id="form1" name="form1" method="post" action=""> <td><?php echo $row_RsDownPayment['RequestID']; ?>-<?php echo $row_RsDownPayment['ProposalID']; ?></td> <td><?php echo $row_RsDownPayment['CustomerLastName']; ?></td> <td><?php echo $row_RsSupplier['SupplierName']; ?></td> <td><?php echo $row_RsDownPayment['PREPAYMENT2SUPPLIER']; ?></td> <td><select name="PaymentMethod" id="PaymentMethod"> <option value="0">Choose</option> <option value="Bank Transfer">Bank Transfer</option> <option value="CreditCard">CreditCard</option> <option value="Cash">Cash</option> <option value="PayPal">PayPal</option> </select></td> <td><?php echo $row_RsStatus['StatusLabel']; ?></td> <td><input name="<?php echo $U='Update'.$row_RsDownPayment['ProposalID'];?>" type="submit" value="Update" /> </td></form> </tr> <?php $con = mysql_connect("host","db","db"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("db", $con); if (isset($_POST['Update121'])) { $query=mysql_query("UPDATE proposals SET StatusID='$_POST[StatusID]' WHERE ProposalID = '$row_RsDownPayment[ProposalID]'"); exit; } ?> <?php } while ($row_RsDownPayment = mysql_fetch_assoc($RsDownPayment)); ?> </table> Hello, I am new to php, and what I need to know and learn is a part of an assignment I normally wouldn't ask for help on the net for an assignment but my teacher is not very helpful and other students are struggling too! I have searched the net inside and out and have tried many things. My problem is that I am trying to remove a line from an array by clicking a delete button. The outpur I need is: a line of text that comes from my text file after it is exploded into an array | With a delete button here next line of text that comes from my text file after it is exploded into an array | With a delete button here etc I have managed to write this much myself - Code: [Select] <?php $file = fopen('fav/fav.txt', 'r'); $file = file_get_contents('fav/fav.txt'); $file_array = explode("\n",$file); array_pop($file_array); foreach($file_array as $line) { echo "<form method='post' action=''>".$line. "<input type='submit' name='post' value='delete'><br>"; $fh = fopen("fav/fav.txt",'w'); foreach ($file_array as $line) { fwrite($fh,$line."\n"); } fclose($fh); } ?> The array_pop deletes from the bottom instead of the line the button is next too, I realise I will need to use and if statement but this is the closest I have gotten. Thanks in advance!!! I have a Php application that already has 2 buttons with input on the index page that perform some functions and output to different Php pages. Works good. How do I add a button with no input that would just perform a function and then just display a popup window showing the contents of a text file? I want to add several of these buttons for different functions and just display the contents of the resulting text files in popup windows. Any help would be greatly appreciated. Thanks in advance. |