Jump to content

thefortrees

Members
  • Posts

    88
  • Joined

  • Last visited

    Never

Everything posted by thefortrees

  1. Hi all, I am developing an online survey tool for a client and wanted community input or any ideas anybody may want to offer. My problem is this: any user of the system can log in and create a custom survey. This user then creates survey codes to give to others. The 'customers' (people who hold survey codes) log in to take a survey using those codes. The survey needs to be broken up into multiple pages (ie - if there are 25 questions, 5 questions per page, so total of 5 pages). However, if the user does not finish the form and submit it at the last page, then the data should not be stored. I am trying to implement the most efficient and effective design for this application. Currently, I am thinking of using a 'temporary_results' table which would store the interim results before the entire survey is completed. If a user completes the survey, then survey data is stored in a 'final_results' table. Also, every survey page will pass the next question numbers to retrieve from the database to the next form. Any input on this? If anybody has developed an application similar to this before, suggestions or comments would be greatly appreciated!
  2. Hi all, Just wondering what you think is more efficient in this situation. I have three tables: items, promocodes, and items_promocodes. items_promocodes is (obviously) a relational table for items and promocodes. If a promocode is applied to any number of items, each item is stored as a new row in items_promocodes with the related promocode as a field. I want to pull all items from the db and check to see if a promocode has been applied to each one. Which one of these is more efficient? $query_allItems = "select items_id from items"; $res_allItems = mysql_query($query_allItems); while ($row_allItems = mysql_fetch_row($res_allItems) { $query_checkItem = "select items_promocode_id from items_promocode where item = '{$row_allItems[0]}'"; $res_checkItem = mysql_query($query_checkItem); if (mysql_num_rows($res_checkItem) > 0) // Item has a promocode applied to it. } $allItemsPromocodes = array(); $query_allItemsPromocodes = "select items_id from items_promocodes"; $res_allItemsPromocodes = mysql_query($query_allItemsPromocodes); while ($row_allItemsPromocodes = mysql_fetch_row($res_allItemsPromocodes)) { $allItemsPromocodes[] = $row_allItemsPromocodes[0]; } $query_allItems = "select items_id from items"; $res_allItems = mysql_query($query_allItems); while ($row_allItems = mysql_fetch_row($res_allItems)) { if (in_array($row_allItems[0], $allItemsPromocodes)) // Item has a promocode applied to it } Is it more efficient to traverse an (possibly enormous) array or to query a database (possibly thousands) of times? I would guess that the query would be more efficient.
  3. ??? I don't really understand what you are asking. If the array key is the same as one that exists already, the value stored in the array will be overwritten with the new value. What bits of information do you want to echo? Just use 'echo'.
  4. Hi all - I am looking to implement a blog into a site. There are many PHP blog packages out there, so I don't need to code it. Any suggestions on which ones to use? I'm looking at Serendipity and SimplePHPblog right now. Thanks!
  5. Hi all, I am tasked with creating a script that takes data submitted in a form on my site, goes to an external site, and populates the fields. For example, if I am at www.mysite.com, I fill out a form with my data (name, address, etc). On form submission, user is redirected to www.someotherdudessite.com and the fields are populated with data from my form. Any ideas where to start?
  6. Solution: update vehicles set vehicles.vehicles_photo_datein = (select max(photo.datein) from vehicle_photos where vehicles.vehicles_photo_datein is null and vehicles.vehicles_id = vehicle_photos.vehicles_id) where vehicles.vehicles_photo_datein is null;
  7. Hi all, I need help with a mysql query. Explanation of problem - I have two tables, vehicles and vehicle_photos. vehicles --------- vehicles_id .... .... vehicles_photo_datein and vehicle_photos --------- vehicle_photos_id vehicles_vehicles_id .... .... photo_datein There are quite a few rows in the vehicles table that have null values for vehicles_photo_datein. I need to take the most recent datein from vehicle_photos that corresponds to vehicles_id in vehicle with null vehicles_photo_datein. I have tried many combinations of queries and can't get it right. Here is what I started with which doesn't work(and will explain what I want better than a paragraph could) update vehicles v, vehicle_photos vp set v.vehicles_photo_datein = (select max(vp.photo_datein) from vehicles v, vehicle_photos vp where v.vehicles_photo_datein is null and v.vehicles_id = vp.vehicles_vehicles_id) where v.vehiclephoto_datein is null; Thanks!
  8. I write to an XML file, then I import the XML file with Excel
  9. Is there any way to define the line break in hexadecimal? I think it is 0x0D 0x0A
  10. Hi all, I am writing to an XML file using PHP then importing the file into Excel as a spreadsheet. Every thing is working fine EXCEPT... I need linebreaks within a string (ie - one cell) and can not figure out/find how to do this. \n and the like do not work properly. Any suggestions?
  11. Remove @ from before all of your $_POST variables. @ denotes silent mode - it tells functions to not return any message on failure. Try this for $query1 $query1 = "SELECT * FROM speciescomplete WHERE species_id = '$species'"; The error you are getting is telling you that the result from your query is not a valid result, meaning your query is incorrect. You do not have a script set in the form action to run. You need this below echo "<p>"; echo '<form method="post" action="form_handler.php">'; form_handler.php is the filename of the script you need to process this form. Next, take the bottom portion of your code and put it into a separate file. I will call it form_handler.php. $author = $_POST['author']; $distribution = $_POST['distribution']; $size = $_POST['size']; $habitat = $_POST['habitat']; $query2= "UPDATE speciescomplete SET author='$author',distribution='$distribution', size='$size', habitat='$habitat' WHERE species_id=$species"; $result2 = mysql_query ($query2);
  12. Hi all - I am trying to implement the "Son of Suckerfish" drop down menu --> http://www.htmldog.com/articles/suckerfish/dropdowns/. Works fine in Mozilla, but in IE, the drop down menu alignment is off and does not disappear onmouseout. Here is my php function that outputs javascript and html: function indexNavBar($current) { $nav = "<script type=\"text/javascript\">" . "sfHover = function() { var sfEls = document.getElementById(\"navmenu\").getElementsByTagName(\"LI\"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=\" sfhover\"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(\" sfhover\\b\"), \"\"); } } } if (window.attachEvent) window.attachEvent(\"onload\", sfHover);" . "</script>"; $pages = array( "Home" => "index.php", "Customer Login" => "survey.php", "Company Login" => "login.php", "About" => "#", "Target Industries" => "industries.php", "Register" => "#", "Contact" => "contact.php" ); $about = array( "TellBuddy" => "about.php", "INQUIZIVE?" => "#" ); $register = array( "Company" => "register_company.php", "Individual" => "register_individual.php" ); $nav .= "<ul id=\"navmenu\">"; foreach ($pages as $name => $url) { $nav .= "<li><a href=\"$url\">$name</a>"; if ($url == "#") { $nav .= "<ul>"; if ($name == "About") { foreach ($about as $n => $u) $nav .= "<li><a href=\"$u\">$n</a></li><br><br>"; } elseif ($name == "Register") { foreach ($register as $n => $u) $nav .= "<li><a href=\"$u\">$n</a></li><br><br>"; } $nav .= "</ul>"; } $nav .= "</li>"; } $nav .= "</ul> <br><br>"; return $nav; } And here is the corresponding CSS code: #navmenu, #navmenu ul { padding: 0; margin: 0; list-style: none; } #navmenu a { display: block; width: 10em; border: 1px solid #0E3B65; } #navmenu li { float: left; width: 10em; } #navmenu li ul { position: absolute; width: 10em; left: -999em; } #navmenu li:hover ul { left: auto; } #navmenu li:hover ul, #navmenu li.sfhover ul { left: auto; } Any help is GREATLY appreciated! Thanks!
  13. maybe you are calling the function with $page == 0?
  14. http://www.zend.com/zend/trick/html-email.php
  15. http://en.wikipedia.org/wiki/Crontab
  16. Hi all - I am having a problem with the onsubmit event handler. Onsubmit, I call the function below. The problems I am having are: 1) If the confirm dialog is used, the redirect does not occur. 2) If the alert dialog is used, even though the function returns false after the dialog, the form still submits! I have been wrestling with this for a while now. Thanks for your help. function enterInfo() { if (validate() == 1) { if (confirm("Would you like to enter our monthly prize drawing? (OK = Yes, Cancel = No)")) { window.location = "enter_info.php"; return true; } else { window.location = "thank_you.php"; return true; } } else if (validate() == -1) { alert('Please respond to all questions.'); return false; } }
  17. Hi all - I need to implement some sorting algorithm. I have a webpage that has n number of questions. The user can reorder the questions as desired with drop down menus. Description of problem: The questions are in position as follows: q1->1, q2->2, q3->3, q4->4, q5->5 If I change the position with the drop down menus, I could possibly have: q1->1, q2->5, q3->3, q4->4, q5->5 Which, upon form submission would have to be reordered before being stored in the database to this: q5->1, q1->2, q3->3, q4->4, q2->5 Any suggestions on where/how to start?
  18. Depends on how you want to sort... You could place all values in an array then use the various PHP array sort functions. Read here to get you started - http://us.php.net/manual/en/function.sort.php
  19. read up on header(). http://us3.php.net/manual/en/function.header.php You can not output ANYTHING (HTML, PHP print statements, etc) to the browser before you redirect with header(). If you want to redirect with it, make sure that it comes before any output to the browser.
  20. Hi all - I am trying to implement a dynamic navigation bar. My problem is as follows - All of my scripts are located in various folders, and as you move to different areas of the site, the links to the other areas of the site will change. For example, I am currently at home.php and the nav bar has references to admin/manage_users.php and companies/view_employees.php, etc etc. If I go to manage_users.php, I am now executing a script in the admin folder. The nav bar still has a reference to companies/view_employees.php, which would make this a dead link. There are lots and lots of directories and subdirectories that one can navigate to, so I don't want to have to write code for a nav bar every time. Is there something like $_SERVER['DOCUMENT_ROOT'] that I can use that will help?
  21. hi all - If I were to pass values from a form and search for values in the database that are similar to my search form values, what purpose does concat() and % serve in this code? $q = //form value; $query = "SELECT i.item FROM vcart_item i, vcart_itemblock ib WHERE i.item = ib.item AND (i.title like concat('%', $q, '%') or i.prodid like concat('%', $q, '%')";
  22. Hi all - I am using Zend Studio to code all of my apps. To run the script and output HTML to the browser, I concatenate all the HTML and function output to a single variable then echo this variable at the end of the script. The problem is this - When I view source in the browser, all of the HTML is in one line. No formatting, no line breaks. So I started using "\n" at the end of every line to format the code. This is extremely cumbersome, and does not provide the proper HTML formatting. Is there anyway to format HTML code within PHP?
  23. Your problem lies with the braces. Each if statement should have separate braces - the way you have it, the last name and email error messages will only print if the name field has not been filled out. Instead of what you have, you need this: if(strlen($name) < $len) { echo "The Name field has not been filled out"; print "<br />"; } if(strlen($lastname) < $len) { echo "The Last Name field has not been filled out"; print "<br />"; } if(strlen($email) < $len) { echo "The E-mail field has not been filled out"; print "<br />"; } Also, There are a few things you can do to improve this script. 1) Use the empty() function to see if a string is empty. Read up on it as well. http://us.php.net/empty if (empty($name)) //Do whatever 2) Create a variable that will receive the desired strings and concatenate each error to the variable. Then check to see if the variable is empty. If it is, then there are no errors and you can echo "Thanks for filling out the form. $errors = ""; if (empty($name)) $errors .= "The name field has not been filled out <br>"; if (empty($lastname)) $errors .= "The last name field has not been filled out <br>"; if (empty($email)) $errors .= "The email field has not been filled out <br>"; if (empty($errors)) echo "Thanks!" else echo $errors;
  24. What do you all think about managing sessions in the database? Does it increase security at all? What are the benefits/disadvantages?
  25. That is javascript you are talking about
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.