Jump to content

patrickm

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by patrickm

  1. A good night sleep helped a lot. I solved it by using the str_replace command. The script checks all answers (default being "") and replaces where needed the info in the template (defined as ANSWER1, ANSWER2, etc.). if ($answer1 <> ""){ $temp-string = str_replace("ANSWER1",$answer1,$text); $text = $temp-string; }
  2. Thanks for the thought, but the setup of the database it different. I'll try to explain: the table contains the following colomns: id, text, question1, specs1, question2, specs2, ... , question15, specs15 Depending the product, certain questions are used/not used (not all have the same 15 questions). Because the questions differ per product, the relevant specs describe what kind of question should be asked (text input, selection with <SELECT>, etc.). When a visitor selects a specific product, the script goes through all questions/specs info and shows the relevant questions. The answers gieven are not stored in the database. The database is used only for asking the right questions
  3. I am having a problem with a script I’m writing. It is using a MySQL database, where it should retreive general information from a product (a template with several variables defined in it in plain text). From the same table, questions are retreived and shown to the visitor of the site. After the questions are answered, the template should be displayed and all variables in it should be substituted with the corresponding answers. In concept, this script works. If I put the template text as a string in the php file, the variables get substituted (example 1). But when it gets the template from a database, it doesn’t work (example 2) ?!? Example 1: // template text $text = “Article: dummy1<br>Length: $answer1<br>Height: $answer2… etc. “; Visual output: Article: dummy1 Length: 315 Height: 504 … Example 2: // template text include("../source/config.php"); $sql = "SELECT * FROM article_info WHERE id = '$id' "; $result = mysql_query($sql) or die (mysql_error()); $dump_data = mysql_fetch_object($result) or die (mysql_error()); mysql_close(); text = $dump_data->text; Visual output: Article: dummy1 Length: $answer1 Height: $answer2 … And yes, displaying $answer1 and $answer2 in example 2 ("echo $answer1;") gives the proper results. I have been going through php documentation, but I can't seem to find it. Could anybody give me clue on this one?
  4. I solved it differently while ($dump_gegevens = mysql_fetch_object($resultaat)) { $temp = explode (":", $dump_gegevens->subgroep); for ($loop = 0; $loop < count($temp); $loop++){ if ($temp[$loop] == $subgroep) { echo "<a href=\"producten.php?code=$dump_gegevens->code&subgroep=$subgroep\">$dump_gegevens->uitvoering</a>"; if ($dump_gegevens->omschrijving <> "*") { echo " $dump_gegevens->omschrijving"; } echo "<br>\n"; } } }
  5. Although I think I got the "explode" function right, I noticed new error messages in the httpd log. Info: the script is called by using: http://www.#####.com/content/productgroep.php?hoofdgroep=1500&subgroep=0 Although the site is working fine, there are "Undefined offset: 4 in productgroep.php at line 123" messages (the number 4/relevant line number can be different, according to the 8 (0-7) options below). include("../source/config.php"); $sql = "SELECT code, uitvoering, omschrijving, subgroep FROM artikel_gegevens "; $resultaat = mysql_query($sql) or die (mysql_error()); while ($dump_gegevens = mysql_fetch_object($resultaat)) { $temp = explode (":", $dump_gegevens->subgroep); if ($temp[0] == $subgroep) { echo "<a href=\"producten.php?code=$dump_gegevens->code&subgroep=$subgroep\">$dump_gegevens->uitvoering</a>"; if ($dump_gegevens->omschrijving <> "*") { echo " $dump_gegevens->omschrijving"; } echo "<br>\n"; } if ($temp[1] == $subgroep) { echo "<a href=\"producten.php?code=$dump_gegevens->code&subgroep=$subgroep\">$dump_gegevens->uitvoering</a>"; if ($dump_gegevens->omschrijving <> "*") { echo " $dump_gegevens->omschrijving"; } echo "<br>\n"; } if ($temp[2] == $subgroep) { echo "<a href=\"producten.php?code=$dump_gegevens->code&subgroep=$subgroep\">$dump_gegevens->uitvoering</a>"; if ($dump_gegevens->omschrijving <> "*") { echo " $dump_gegevens->omschrijving"; } echo "<br>\n"; } if ($temp[3] == $subgroep) { ... } .. etc. if ($temp[7] == $subgroep) { ... } The field $dump_gegevens->subgroep contains data with the following format: *:*:*:*:*:*:*:* where * can be a 4 digit value or a * (default when not used). For example: 1002:1502:1604:*:*:*:*:* Could the problem be the fact that php treats the numbers as numerical values instead of text? Just asking because altering the * values within the complete database is a hell of a job, especially if it's done without use (when the problem lies somewhere else)...
  6. Unbelievable... many times I've looked over de code and never saw it... I copied it from another piece of code I used and $titel isn't used here. Thanks for the help
  7. I've build an admin section to a website where products are presented. The admin page allows the logged in user to change/adapt certain values of a selected product. Although the website/admin page is working without any problem, I come across error messages in the Apache/httpd logfiles: The code the error message is referring to: if ($actie == ""){ include("../source/config.php"); $sql = "SELECT * FROM artikel_gegevens ORDER BY id"; $resultaat = mysql_query($sql) or die (mysql_error()); echo "<form action=\"admin-artikel-gegevens.php?actie=aanpassen\" method=\"post\">\n"; echo "<select name=\"code\" id=\"code\" class=\"snelstart\">\n"; echo "<option value=\"\">Maak een keuze ...</option>\n"; while ($dump_gegevens = mysql_fetch_object($resultaat)) { ==> if ($dump_gegevens->titel <> "*"){ echo "<option value=\"$dump_gegevens->id\">$dump_gegevens->uitvoering</option>\n"; } } echo "</select>"; echo " "; echo "<input type=\"submit\" name=\"submit\" value=\" Go! \" class=\"button\">\n"; echo "</form>\n"; mysql_close(); } I've gone through various resources but can't seem find draw this one out.. ???
  8. There is no solution for this ???
  9. The same "problem". Whatever I enter, will be displayed besides the --> and the input stays at its place.
  10. I'm trying to build a website with a simple text input option. After the input, the input is checked and acted upon accordingly. This is followed by a new input line. For example: > input: test "test" is not known to me > input: _ So far, I've been trying things with the "do-while" loop (see code below), but so far, all I seem to get is a fixed input box and the "respons" being displayed below it. <?php do { echo "<form name=\"form\">Input:"; echo "<br><input value=\"\" size=\"30\" type=\"text\" name=\"invoer\">"; echo "</form>"; if ($invoer == "info"){ echo "<br>blah blah blah/n"; echo "<br>blah blah blah"; } if ($invoer == "help"){ echo "<br>Commands: help, clear, info"; } if ($invoer == "etc"){ echo "<br..etc.."; } } while ( $jedi == "1" ); ?> Note: there is no need (for me) to be able to break out of the loop (thus "jedi = 1" will never be so).
  11. On a website, I have written a piece of code which allows editing of product specifications. The data is pulled from a MySQL database and displayed in an form-like page with <input> and <textarea> elements. But I can't seem to find a good workaround for the following problem: echo "<p><b>Omschrijving</b>"; echo "<br><input value=\"$dump_gegevens->omschrijving\" type=\"text\" size=\"60\" name=\"form_omschrijving\">"; echo "</p>"; Displays an input field which is filled already by the proper data (in the above example called "omschrijving"). Some of the products have a description in this field with " in it. If I enter the following string (placed between [ ] for clearity) [blah blah blah ("whatever")] if will only parse the input until the first " (obvious). So, if I use \", it won't work either (with <input>). The only way around it is to use &#034; or double '. If I use &#034; I end up with a new problem: the next time the specs of this product gets edited, the <input> field shows the correct html/php output and the &#034; get replaced by " (and saving it will cause this field to be truncated after the first (displayed) "). Question: how can I display the content of a string ($whatever->content) in such a way that the content is listed "as it is" (like < pre > in html) and &#034; would become visible?
  12. Thanks for the suggestions. I've done some searching and found a useful page on Wikipedia. Super!
  13. I'm having problems cracking a SQL/PHP nut. Situation: table 1 contains several information about products (among the field, there are $code and $product_description). T ???able 2 contains specific information with which can be determined which product you need (it also contains the field $code). From table (no.2) I select the right products when a certain variable = "something". The outcome is processed using while ($dump_resultaat = mysql_fetch_object($resultaat)) { ... } But here it comes ... in this loop, the valid info from field $code in $dump_resultaat should be used to retrieve information from table 1 in which there is also a field called $code. $code is used as a reference in both tables. How do I build this? I've tried to combine things in PHP, but unfortunately to no avail. Any pointers would be appriciated!
  14. I could not find an edit button ??? One thing I put in my previous post wrong: it shouldn't work on onmouseover, but onmouseout. Sorry about that.
  15. Hello everybody. Hopefully you can help me with a small thing I'm working on. I am designing a page on which helps visitors determine which product they need by answering some questions/making certain selections. I've copy/pasted a working routine, but it is a very crude method. Note: on the spot where it displays the variables, there will be eventually a routine which will send a request to a MySQL database and display the outcome. <table width="600" cellspacing="0" cellpadding="0" border="0"> <tr> <td width="200" valign="top"> <?php echo "<form action=\"selector.php\" method=\"post\">\n"; echo "<select name=\"situatie\">"; echo "<option value=\"binnen\""; if ($situatie == "binnen"){ echo " selected "; } echo ">Binnen situatie</option>\n"; echo "<option value=\"buiten\""; if ($situatie == "buiten"){ echo " selected "; } echo ">Buiten situatie</option>\n"; echo "</select>"; echo "</select>\n\n"; echo "<br><br>\n\n"; echo "<select name=\"type\">"; echo "<option value=\"aanslag\""; if ($type == "aanslag"){ echo " selected "; } echo ">Aanslagdeuren</option>\n"; echo "<option value=\"pendel\""; if ($type == "pendel"){ echo " selected "; } echo ">Pendeldeuren</option>\n"; echo "<option value=\"wissel\""; if ($type == "wissel"){ echo " selected "; } echo ">Wisseldeuren</option>\n"; echo "</select>"; echo "</select>\n\n"; echo "<br><br>\n\n"; echo "<input type=\"submit\" name=\"submit\" value=\" Go! \" class=\"button\">\n"; ?> </td> <td width="400" valign="top"> <?php echo "$situatie"; echo "<br>"; echo "$type"; ?> </td> </tr> </table> Is it possible to use mouseover on each selection-field seperately (instead of all of them at once using a "submit" button) to display the outcome without using "reload the same page" ?? In other words, I want to create a page with "life" (MySQL) results as soon as a visitor changes one of the selection fields.
  16. Ouch .... And I thought it would be more difficult  :-[ Thanks!
  17. Being new to the world of PHP and MySQL, I have a problem for which I can't think of an answer. At the moment I am creating a website on which there will be a database with several companies in it. What I want to create is a dropdown selectionmenu (using < s e l e c t > and < o p t i o n >) with all cities from the companies on the database in it. But the problem is that several different companies are located in the same city. So using SELECT from the cities-table will result in a (faulty) list with double/triple cities on it. My question: how do I select and sort out the cities and create a list on which each city is listed only once? Any help would be more than welcome  8)
×
×
  • 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.