PHP - Need A Dynamic Subform
I want to build a webpage where an employee can key in an order, including the order details. Building an entry form for just the order is easy enough, because it is simply one webpage with a set number of fields. And when you need to enter in a new order, you simply load a new blank form. But the order details part seems trickier, because one order can have one-to-many order details, and so I need a subform that expands as more items are entered. For instance, let's say this is in a restaurant, and a large group of people walk in. There is no telling how many items they might order, but I would need a way to let the waiter keep adding items to their bill as long as necessary. On the web, I'm not sure even where to begin with this?!
Edited May 18, 2019 by SaranacLake Similar Tutorialsin a table cell i have a select statement with options from 1 to 10. Onchange (if they select 3), i want to display a subform in the same table cell where the person can add the for the three children name (Textfield) sex (select: M/F) date of birth (select for day, select for month and select for year) currently, i've tried something with javascript but it's only saves the child_id and parent_id and does not save the rest. Moreover i have no clue how to populate the date of birth. Please if you have any solutions, tell me! Any help is very much appreciated! Folks, I need help (Php code ) to generate a Dynamic Text on a Base Image. What i want to do is, to make this Image as header on my Site and to make this Header Specific to a Site, i want to Add the Domain Name on the Lower Left of the Image. Got the Idea? Here is the Image link: Quote http://img27.imageshack.us/i/shoppingheader1.jpg/ PHP Variable that holds the Domain name is: $domain All i need the Dynamic PHP Codes that i can put on all my sites to generate this Text on Image (Header) Dynamically... May Anyone Help me with this Please? Cheers Natasha T. Hi all I need to combine these two scripts: Firstly, the following decides which out of the following list is selected based on its value in the mySQL table: <select name="pack_choice"> <option value="Meters / Pack"<?php echo (($result['pack_choice']=="Meters / Pack") ? ' selected="selected"':'') ?>>Meters / Pack (m2)</option> <option value="m3"<?php echo (($result['pack_choice']=="m3") ? ' selected="selected"':'') ?>>Meters / Pack (m3)</option> <option value="Quantity"<?php echo (($result['pack_choice']=="Quantity") ? ' selected="selected"':'') ?>>Quantity</option> </select> Although this works OK, I need it also to show dynamic values like this: select name="category"> <?php $listCategories=mysql_query("SELECT * FROM `product_categories` ORDER BY id ASC"); while($categoryReturned=mysql_fetch_array($listCategories)) { echo "<option value=\"".$categoryReturned['name']."\">".$categoryReturned['name']."</option>"; } ?> </select> I'm not sure if this is possible? Many thanks for your help. Pete Hello! If you search Google, you'll notice the URL: http://www.google.com/webhp?hl=en#hl=en&source=hp&q=php+freaks&aq=f&aqi=g10&aql=&oq=&gs_rfai=CtdaTdtdRTNnPD5HuzASZtMWiCgAAAKoEBU_Q0ZT5&pbx=1&fp=19d754eee0b4f223 You can copy that URL anywhere you like... and the user will still see the same results. So basically the URL dynamically does an action, and accesses the database. How on do I make a URL like this? Meaning when you change the URL parameter values, it request a slightly different database query? Does that make sense? Similarly with NexTag.com: http://www.nextag.com/serv/main/buyer/ProductCompare.jsp?search=camera&page=0&node=500001&psort=%2FDigital-Cameras--zzcameraz500001zB6z5---html&zipcode=&cptitle=657166355&cptitle=656751324&cptitle=620051906&cptitle=705150048 That was a Dynamically made URL (I selected from check boxes which products to compare) and it makes that URL so anyone can see those products. Any ideas on how to do this? More examples on the URL: http://www.cars.com/go/compare/modelCompare.jsp?myids=9721,11439 (i select the cars, it generates that URL. Notice the IDs 9721,11439) Is there a way to create dynamic content without the use of a Content Management System? I simply want to click on a link in my navigation menu and have that display the content in a div section and keep the content in a separate folder on the server. I didnt want to have to use a CMS to accomplish that because every other feature of it will be unused as I just simply want to display the content in a div when I click on the link. I use a simple test server on my Home PC that I use to format the articles in html from documents I have wrote in LibreOffice, so I dont really need all the features and sophistication of full blown CMS. But I also dont want a bunch of different files in my root folder if I can avoid it. I would rather keep the content in a separate folder and just pull it from there and display it on the main page when the link is clicked. Anyway, I dont know if its even possible or if its the best way, so I am open to suggestions as well. Some of the documents are quite long (like several chapters) and some are much shorter (just a few pages). Any help and ideas are much appreciated. Hi guys. I am having a hard time finding a solution for this, is it possible to get not the value of a dropdown (oh what's it called??? ) but what is in between of the <option> tag?like, Code: [Select] <select name="catID"> <option value=$row['c_id']>$row['c_name']</option> and save it to the database??cuz I'm using a dynamic dropdown which bases the content of another dropdown by the id of the previous. And so, if i save it to the database, instead of for example "BSA" is saved, the id of "BSA" which is "1" is saved..any ideas guys? Hello: I am trying to make a StyleSheet updateable from my admin panel, but I'm not sure if what I want to do is possible. So ... I have a TEXTAREA in my admin panel that writes to the DB just fine. it has styles like: Code: [Select] body { margin: 5px 0; padding: 0; background-color: #ebe9e6; background-image: url('../images/Site-BG2.jpg'); background-position: center bottom; background-repeat: no-repeat; background-attachment: scroll; font-family: arial, sans-serif; font-size: 100%; line-height: 1.4em; } ... Etc... On the frontend, it writes into the StyleSheet just fine like: Code: [Select] <?php include('myConn.php'); //contains your mysql connection and table selection $query=mysql_query("SELECT * FROM myStyleSheet") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $myPageData=$result['myPageData']; } ?> <?php echo $myPageData; ?> So, what I want to see is if I can somehow pull the styles onto the page like: Code: [Select] <link rel="stylesheet" type="text/css" href="include/StyleSheet.css" /> Now, if I do it as listed above it and look at the code it displays the Code: [Select] <?php include('myConn.php'); //contains your mysql connection and table selection Etc... If I do it like Code: [Select] <link rel="stylesheet" type="text/css" href="include/StyleSheet.php" /> It displays the styles fine, but the browser doesn't read it as a StyleSheet and therefore the page doesn't get formatted. So, is there any way to make this work? Anyone have any ideas about this? The idea is so I can manage the Styles via an admin panel remotely without having to login with web editing software. Thanks. Hey guys does anyone know of a good dynamic directory solution? What i mean by this is when i am creating an application and i use require_once 'includes/config.php'; and then i create a class that needs the config file so i include it into the class like so: require_once '../include/config.php'; then i make a new folder named member then i have to require this class (created above) and it fails to find the directory. What would be a good solution for this? Thanks guys!! Hi all This probarly looks really bad but im trying to replase tags that change. So far it only replaces the last tag and not well either. I will try to show you Code: [Select] function testfunc($value) { if ($value=='gallery'){$return .= "this gallery has worked = --$value--";} if ($value=='email'){$return .= "this email has worked = --$value--";} return $return; } $test = "this is a test {%email%} message {%gallery%} rtfgdsfgdsfg"; $test = preg_replace("#(.*){%(.*?)%}(.*)#is",'$1' . testfunc('$2') . '$3', $test); echo $test; this outputs this is a test {%email%} message rtfgdsfgdsfg but im trying to get this this is a test this email has worked = --email-- message this gallery has worked = --gallery-- rtfgdsfgdsfg Im sure im way off but I hope you can understand. Thank you for taking the time to read this post. Hi, I hope someone can help. I currently have a page that includes the main page after login, however I am looking into changing this so that when a user logs in they get 3/4 linked images that, when clicked dynamically load/include the page based on the select i.e. user selects the image laptop, that has a hyperlink, it loads the laptop page. If anyone has any ideas or suggestion,i'd appreciate it. Let's see if I can explain this ok.. Basically I have a site and the page product categories use dynamically created URL's. I want to use these URL's to put on my products so I can list all the categories each product is in. But, as these URL's are not stored anywhere I'm not sure how to go about calling them. Is the best way going to be to modify the site to store the page URL's in MySQL? Or could they be stored within variables in PHP? A little guidance would be great! Thanks in advance How can I go about making dynamic pages? eg. user types "phpfreaks.com/index.php?page=name" I'm having trouble getting the dynamic data from my <select> menus to write into my MYSQL database. Can anyone see what I'm doing wrong here? First post btw The output looks like this, which is obviously wrong: Code: [Select] <html> <head> </head> <link rel="stylesheet" type="text/css" href="./css/newuser.css" /> <body> <?php session_start(); require 'default.inc.php'; ?> <?php if (isset($_POST['amount'])): $host = 'localhost'; $user = 'user'; $pass = 'password'; $conn = mysql_connect($host, $user, $pass); if (!$conn) { exit('<p>Unable to connect to the database server</p>'); } if (!@mysql_select_db('spikesusers')) { exit('<p>Unable to locate the database</p>'); } $locationname = $_POST['donor']; $donorid = mysql_query("SELECT id FROM donors WHERE locationname='$locationname'"); $amount = $_POST['amount']; $year = $_POST['year']; $type = $_POST['type']; $typeid = mysql_query("SELECT id FROM donationtype WHERE type='$type'"); $player = $_POST['player']; //$playerid = mysql_query("SELECT id FROM players WHERE $sql = "INSERT INTO donations SET donorid='$donorid', amount='$amount', yearofdonation='$year', typeid='$typeid'"; mysql_query($sql); ?> <div class='standard'> <h1>Donation Management</h1> <?php if ($sql) { echo "New donation added "; echo "<p></p>"; echo "<a href=managedonations.php>Back to donation management</a>"; exit(); } else { echo "Error adding new donation"; echo "<a href=adddonation.php>Try again</a>"; exit(); } ?></div> <?php else: $host = 'localhost'; $user = 'user'; $pass = 'pass'; $conn = mysql_connect($host, $user, $pass); if (!$conn) { exit('<p>Unable to connect to the database server</p>'); } if (!@mysql_select_db('spikesusers')) { exit('<p>Unable to locate the database</p>'); } $donor=@mysql_query('SELECT id, locationname FROM donors'); ?> <div class='standard'> <h1>Donation Management</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Donor: <select class="text" name="donor"> <option value=new>Add a new donor...</option> <?php while ($donors=mysql_fetch_array($donor)) { $donorname=$donors['locationname']; echo "<option value='<?php echo $donorname;?>'>$donorname</option>"; //echo "<option value='hi'>hi</option>"; } ?> </option> </select> </label><br /> <label>Amount: <input class="text" type="text" name="amount" class="text" /></label><br /> <label>Year of donation: <select class="text" name="year"> <option value='2011'>2011</option> <option value='2010'>2010</option> <option value='2009'>2009</option> </select> </label><br /> <?php $player=@mysql_query('SELECT id, firstname, lastname FROM players'); ?> <label>Player: <select class="text" name="player"> <option value="player" selected="selected"></option> <?php while ($players=mysql_fetch_array($player)) { $playerfirstname=$players['firstname']; $playerlastname=$players['lastname']; echo "<option value=player>$playerfirstname $playerlastname</option>"; } ?> </select> </label><br /> <?php $type=@mysql_query('SELECT id, type FROM donationtype'); ?> <label>Donation type: <select class="text" name="type"> <?php while ($types=mysql_fetch_array($type)) { $donationtype=$types['type']; echo "<option value=type>$donationtype</option>"; } ?> </select> </label><br /> <input type="submit" value="SUBMIT" class="buttons"/> <input type="button" name="Cancel" value="CANCEL" onclick="window.location = 'managedonations.php'" class="buttons"/> </form> </div> <?php endif; ?> </body> </html> Hi all, completely new at this and have got myself stuck! I am trying to display a thumbnail image by connecting to my database and retrieving the URL that points to the image. I know that the connection is working but I can't seem to get it to point to the image. Probably something really simple. Here's my code: Code: [Select] <!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=iso-8859-1" /> <title>Image Swap Using CSS</title> <style type="text/css"> body { margin: 0; padding: 0; background-color:#000000; } img { margin: 0; padding: 0; border: none; } .test { margin: 0; padding: 0; width: 99px; height: 130px; } .test a:hover img { visibility:hidden; } </style> </head> <body> <?php // connect to the database mysql_connect("********", "****") or die(mysql_error()); mysql_select_db("eliteescorting") or die(mysql_error()); $start=0; // expand on the searches $data=mysql_query("SELECT * FROM escorts WHERE base = 'manchester' ORDER BY RAND()"); $num_results=@mysql_num_rows($data); for($ii = $start;$ii < $num_results; $ii++){ ?> <div class="test"><a href="#"><img src="<?php echo $data[$ii]['thumb'];?>" /></a></div> <?php } ?> </body> </html> In my mySQL field 'thumb' contains the full URL of the image ie http://www............ This is just for testing, I'll get round to sorting out security issues later. Your help will be greatly appreciated! Regards, Nortski. Holy smoke, it has been a looooooong time since I have been here. Love the new look of the site btw. Well I am working on a new project for my church. The idea is an email to SMS program. So one use of this would be that if there is a youth activity I could send a message to the entire youth group with one message. I am trying to figure out something specific with it. I need to create a form that grabs info from the database. So more specifically what I need is one drop down that will have "Youth Group", "Parents", "Deacons", etc. now based on what I select I need the second drop down to populate with the corresponding people in that group. Now I want an "All" to be in the drop down to which would let me send the message I type to ALL people in the desired group but to also have the individual names come up just in case I need to do a specific person. How would I go about doing something like this? I have done much research and cant quite find what I would need to do. Any help would be GREATLY appreciated. I really can't get my head around this dynamic drop box. What I want is for a drop box to be populated with values in my database. I have this that connects to my SQL and picks out the table required: function displayUsers(){ global $database; $q = "SELECT username," ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username"; $result = $database->query($q); ... I then have this to pick out any errors, and also using the num_rows to get the number of rows (values) there a $num_rows = mysql_numrows($result); if(!$result || ($num_rows < 0)){ echo "Error displaying info"; return; } if($num_rows == 0){ echo "Database table empty"; return; } From here, I guess I want the num_rows to keep 'adding on' the number of <option value=""> in my selection box according the number of values I have in my database. At this point, I can pull out the values into a dynamic table ... but I want it into a drop box -- but I'll but up the code for the dynamic table so you can get an idea: /* Display table contents */ echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"; echo "<tr><td><b>Username</b></td></tr>\n"; for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"username"); echo "<tr><td>$uname</td></tr>\n"; } echo "</table><br>\n"; } I hope you can use the code above to help me develop this darn drop box! Thanks, Ollie! Im working on a site and particularly the photo gallery section. I want to display 9 images on 3 rows (3 per row). And im stuck. Te only way i can get the images to show up not one on top of the other is by using a table. but how can i tell the table to only put 3 <td>'s then to <br> Heres my code so far... <?php $sql_images = mysql_query("SELECT * FROM photos ORDER BY upload_date DESC LIMIT 9"); while($row = mysql_fetch_array($sql_images)){ $photo_id = $row["id"]; $location = $row["location"]; $display_pics .= ' <td width="125px"> <a href="image.php?id='. $album_id .'" class="black"><img src="images/uploads/thumbs/' . $location . '" /></a> </td>'; } ?> Then to display it ... Code: [Select] <table width="top" cellpadding="10" cellspacing="20"> <tr> <?php echo $display_pics; ?> </tr> </table> My goal is to do it as simple as possible! Can anyone help? If you don't think tables are the way to go im open to any suggestions. I've thought about <divs> but then the images show up one on top of the other and not beside each other. By the way all the images are a max of 100px heigh and 100px wide Thanks for any help or suggestions! Hi, I am using php dynamic listing from database. it is working but I wanna integrate to a horizontal css menu how can i integrate my codes to any css horizantal dropdown menu. thans. here my dynamic list. <?php function sinirsiz_kategori($parent) { $sql = mysql_query("SELECT * FROM kategoriler ORDER BY id DESC"); while($row = mysql_fetch_array($sql)) { $diziler[$row['id']] = array('baslik' => $row['baslik'],'parent' => $row['parent']); } $has_childs = false; foreach($diziler as $key => $value) { if ($value['parent'] == $parent) { if ($has_childs === false){ $has_childs = true; echo "\t<ul>"; } echo "<li><a href=\"".$value['baslik'].".php\">".$value['baslik']."</a>"; sinirsiz_kategori($key); echo "</li>\n"; } } if ($has_childs === true) echo "</ul>"; } ?> <?=sinirsiz_kategori(0)?> trying to be able to store client information in mysql db for reference later in an admin area. The code I have so far allows me to list the client names, but once I "select" the name I want it to show the rest of the database information stored for that user (email, height, weight, phone number, etc...) which it currently is not doing. Any and all help will be greatly appreciated, tired of struggling through this blindly. Code: [Select] <? // Connect database mysql_connect("localhost","",""); mysql_select_db("mydb"); if(isset($select)&&$select!=""){ $select=$_GET['select']; } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <form id="form1" name="form1" method="get" action="<? echo $PHP_SELF; ?> "> Client Name : <select name="select"> <option value="">--- Select ---</option> <? // Get records from database (table "users"). $list=mysql_query("select * from users order by id asc"); while($row_list=mysql_fetch_assoc($list)){ ?> <option value="<? echo $row_list['id']; ?>" <? if($row_list['id']==$select){ echo "selected"; } ?>><? echo $row_list['name']; ?></option> <? } ?> </select> <input type="submit" name="Submit" value="Select" /> </form> <hr> <p> <? if(isset($select)&&$select!=""){ // Get records from database (table "users"). $result=mysql_query("select * from users where id='$select'"); $row=mysql_fetch_assoc($result); ?> Information about <strong><? echo $row['name']; ?></strong> client...</p> <p><? echo $row['email']; ?><br> ........................................<br> ........................................ <? // End if statement. } // Close database connection. mysql_close(); ?> </p> </body> </html> So we just started php after learning a month of HTML, and we need to create a website with a page that allows the admin to change the colors and font size, header, etc on the webpage itself via forms. E.g. I'm on the site and I can use a drop down menu to change the background to "blue" for example. No need to go edit the CSS file or anything. How can be this done? My second and final question is how would I write code that allows my website to have users "log in" to their account so they can edit their page? Thanks a lot, I'm not good at PHP yet I've just started so please keep that in mind:) - Kranti |