Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Have you tried outputting $request to see what it contains? public function __construct($request){ print '<pre>' . print_r($request, true) . '</pre>'; //...
  2. To set the color based on the GET variable, you could run a switch statement after $capacity is set. if (isset($_GET['id'])) { $id = $_GET['id']; $stmt = $conn->prepare("SELECT * FROM MATRIX WHERE OBJECTID=:id"); $stmt->execute(array(':id' => $id)); $row = $stmt->fetch(PDO::FETCH_ASSOC); $object_id = $row['OBJECTID']; $capacity = $row['Capacity']; $ownership = $row['Ownership']; } //DETERMINE DROPDOWN COLUMN COLOR $bgColor = 'grey'; //whatever you want to use for the default color switch($capacity) { case 'green': $bgColor='green'; break; case 'amber': $bgColor='yellow'; break; //etc... } ?> Then you can use the new $bgColor variable in your HTML code. <td style="background-color:<?=$bgColor;?>"><label> <select name="txt_capacity" class="textfields" id="capacity"> <option id="0">Select One</option> <?php require_once('include/database.php'); $stmt = $conn->prepare("SELECT * FROM MATRIX_DROPDOWNS"); //...
  3. Do you have any other JavaScript on the page? If so, does that code stop working also when the jQuery code is present? When a browser comes across a JavaScript error, the rest of the JavaScript code tends to stop working also. Have you looked in your browser's Console to see if it's throwing any JavaScript errors?
  4. session_start() needs to be called before anything is outputted to the screen. If you need further help, you'll need to post some code.
  5. Just be aware that the for attribute in the <label> tag needs to match the id attribute in the <input> tag. Otherwise, the <label> tag won't do anything. Or, if you want, the <label> tag can be wrapped around the <input> tag. Then the for and id attributes are not needed. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
  6. I just re-read Reply #5. Are you looking to limit the number of options displayed in the dropdown based on the color selected in index.php? Or are you just trying to change the background color of the dropdown?
  7. Let's deal with the GET variable from index.php first. You are utilizing the variable here: $object_id=''; $capacity = ''; $ownership = ''; if (isset($_GET['id'])) { $id = $_GET['id']; $stmt = $conn->prepare("SELECT * FROM MATRIX WHERE OBJECTID=:id"); $stmt->execute(array(':id' => $id)); $row = $stmt->fetch(PDO::FETCH_ASSOC); $object_id = $row['OBJECTID']; $capacity = $row['Capacity']; $ownership = $row['Ownership']; } And it sounds like $capacity is the variable that indicates which color was selected, correct? If so, are you able to incorporate $capacity into the following query? $stmt = $conn->prepare("SELECT * FROM MATRIX_DROPDOWNS"); Does $capacity match the values stored in your "colors" column in the MATRIX_DROPDOWNS table?
  8. If you haven't already, you could try Reply #3.
  9. Instead of using the placeholder attribute, have you tried putting the instructions outside of the <input> tag? Maybe something like this: $attr_input = "<input type='text' id='attribute_$tracker_alert_attribute_id' name='attribute_$tracker_alert_attribute_id' value='$value' $trigger_on_change_html> $entry_instructions";
  10. You could use explode() again. <?php function func($text) { $array = explode(' ', $text); foreach($array as $currArg){ $currArg = explode('=', $currArg); print '<pre>' . print_r($currArg, true) . '</pre>'; } } func("arg1=Test1 arg2=test1 arg3=test3"); ?>
  11. I'm not sure what you are asking. Are you looking to incorporate a dropdown into the code above? Is there a dropdown somewhere else on your website that connects to the above code?
  12. Basically, you could do something like this //Explode $str to an array, each line separated by line breaks \n $arr = explode("\n", $str); $values_withCommas = array(); //If row contains "," add it to an array and print it foreach ($arr as $currLine) { if (strpos($currLine, ',') !== false) { $values_withCommas[] = $currLine; } } //Display result echo implode('<br>', $values_withCommas);
  13. To loop through the array, you could use a foreach loop: http://php.net/manual/en/control-structures.foreach.php That way you wouldn't need to worry about a counter. But if you need the counter, for whatever reason, you could use the count() function. http://php.net/manual/en/function.count.php To determine if a line contains a comma, you could avoid regular expressions by using strpos() instead. http://php.net/manual/en/function.strpos.php Note that you'll want to read the warning under the Return Values section.
  14. Do you know if the value variables (eg. $value1) contain arrays? You could check using code like this: echo '<pre>' . print_r($value1, true) . '</pre>'; Also note that the following line is missing dollar signs before the value variables: $array = array(value1, value2); And with the following line, do you expect a comma-separated list of both $value1 and $value2? echo $comma_separated = implode(",", $array); In other words, do you expect the following output: asasas,sdsddd,asasas,sdsdsd If so, you could use array_merge() to combine the arrays. More information can be found here: http://php.net/manual/en/function.array-merge.php Note that the following line just creates an array of arrays: $array = array_merge($value1, $value2);
  15. Did you post your code or the thing you found on the internet? It will be easier to help if we see the problem code.
  16. You could assign all the data, in the while loop, to a multidimensional associative array. And then loop through the multidimensional associative array to generate the HTML table. If done correctly, you can use the count() function to determine how many rows to span the "OnGoing" value, for example, across. More information about multidimensional arrays and multidimensional associative arrays can be found here: http://webcheatsheet.com/php/multidimensional_arrays.php On a related note, you could use the nl2br() function instead of all those calls to str_replace().
  17. Note: the original post was made in April 2012.
  18. Did you try removing the asterisk and spaces before the keywords like "Plugin Name"? Never mind. I just pasted your header into a PHP file and uploaded it to a WordPress website. Everything worked fine for me. Did you name the file with a .php extension?
  19. Have you tried something like this $xmlstr = '<property>'; foreach ($files as $file) { $xmlstr .= '<prop_detail>'; combineXML($file); $xmlstr .= '</prop_detail>'; } $xmlstr .= '</property>';
  20. For what it's worth, you are assigning a string to $message on the following line: $message = " Since your string starts with a double quote ("), PHP will look for the next double quote to determine where the end of the string is. So basically, PHP thinks this is the string to assign to $message: " <!DOCTYPE html " ...and it's not going to know what to do with the rest, hence the error. To prevent PHP from cutting the string off early, you need to use care with double quotes that appear within the [double-quoted] string. You could replace them with single quotes ('), where possible. Or you can escape the double quotes (\"). Or you could even consider using the heredoc or nowdoc syntax. More information about all of these tactics can be found here: http://php.net/manual/en/language.types.string.php
  21. For what it's worth, here's a quote from the forum rules:
  22. Is your form and the final destination (website.com/abc.php) under the same domain name? If so, is there a reason you don't want to use a header() redirect?
  23. Instead of passing the data directly to "website.com/abc.php", you can pass it to a PHP script that processes the data and displays the CAPTCHA. The CAPTCHA form would then send the data, maybe through $_SESSION variables to a script that validates the CAPTCHA response. If everything checks out, the script could perform a header() redirect to "website.com/abc.php".
  24. You could give it a shot <?php $sql = mysql_query("SELECT * FROM database where id=$id"); while($do=mysql_fetch_array($sql)){ echo "<div>{$do['id']}</div>"; } ?> Note that I added a semi-colon after the call to mysql_query(). And in case you are not aware, the mysql_* functions have been removed from the newest version of PHP. You need to switch to PDO or MySQLi soon. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
  25. Is the href attribute pointing at the correct location for the file? Have you tried using a root-relative link? More information can be found here: http://www.motive.co.nz/glossary/linking.php?ref#root
×
×
  • 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.