Solutions
-
andy9l's post in Find/change in array was marked as the answerThis seems a bit tidier...
http://jsfiddle.net/andy9l/q11d6Lde/
-
andy9l's post in Submitting multiple forms with single button was marked as the answerUse one single form?
-
andy9l's post in Menu Not Showing - Help Rqd was marked as the answerYou're including jQuery twice. Possibly conflicting?
-
andy9l's post in Count characters in text area populated from database was marked as the answerThis should work, and it's a bit more expandable. Add as many fields as you need without needing more Javascript.
http://jsfiddle.net/bkXw3/
-
andy9l's post in Changing content using php based on selected option was marked as the answer$(function(){ // This is just a jQuery shorthand for: onPage load, do everything inside here...
// This adds an onchange event handler to the select element
// with the data-role value of 'initial-selector'
$("select[data-role='initial-selector']").on('change', function(){
// Gets the selected index of the initial-selector select element
// the selected index is an integer value 0 -> number of options-1
var index = this.selectedIndex;
// Hide all of the other selects using a simple js-hide class
// this line hides all select elements with that class
$("select.hide-js").hide();
// Now show the appropriate select element using the index
// we got previously – uses the data-role property again
// If the index is 1, then this line chooses selector-1
// if the index is 2, then this line chooses selector-2, and so on...
$("select[data-role='selector-" + index + "']").show();
});
// onLoad, just hide the select boxes initially – this is better than
// CSS as it allows for non-js users to still use the form at least
$("select.hide-js").hide();
}); // End of the initial function (jQuery shorthand onPage load) -
andy9l's post in Selecting multiple values from a database was marked as the answerUsing my table structure, you would use a query along the lines of:
SELECT shoes.name as Shoe, socks.name as Sock, (shoes.cost+socks.cost) as TotalOrderCost, choices.MemberID as MemberID FROM choices JOIN shoes on choices.ShoeID = shoes.ShoeID JOIN socks on choices.SockID = socks.SockID WHERE choices.MemberID = 1Switch the MemberID accordingly.
That will return the following result:
+---------------+------------+----------------+----------+ | Shoe | Sock | TotalOrderCost | MemberID | +---------------+------------+----------------+----------+ | Nike Shoe One | Blue Socks | 15.98 | 1 | | Nike Shoe Two | Red Socks | 14.98 | 1 | +---------------+------------+----------------+----------+ -
andy9l's post in PHP Include file within another included file was marked as the answerTry:
include(__DIR__ . '/file2.php'); -
andy9l's post in How to convert plain text entry in form to numbered list? was marked as the answer$bullets = preg_split("/\\r?\\n/", $string); // $string = $_POST['your_input']
echo "<ol>";
foreach ($bullets as $bullet) {
echo "<li>" . htmlentities($bullet) . "</li>";
}
echo "</ol>"; -
andy9l's post in htaccess rewrite (WHY?) was marked as the answerThe above code is actually very simple, and nearly every website will use something very similar.
Your code is forcing the "www." in the domain name - thus Google won't index two copies of your page. An example would be:
http://www.yourdomain.com/page1.html http://yourdomain.com/page1.html
Technically the same page, but arguably on two different domains. Your code prevents this, by redirecting any requests that are missing the www. to the appropriate www. domain.
-
andy9l's post in Contact Form was marked as the answer$_Post should be capitalised to $_POST
http://php.net/manual/en/language.variables.basics.php
-
andy9l's post in Soundcloud stratus 2 player not working was marked as the answerYou're using jQuery 1.9.x, and the current Stratus 2 plugin relies on $.browser which was removed in jQuery 1.9.x. The solution is to switch to using a lower version of jQuery (1.8 or lower), or use jQuery Migrate.
-
andy9l's post in **help** not sure where to start! was marked as the answerWell, the method I suggested will work...
HTML form as input Grab inputs using $_POST in PHP Handle the selecting of certain fonts (switch statement, or 'if's) Use Imagick to add the font to the relevant stock image file, and store this new temporary file in a /temp folder (timestamp if you want) Return this new location to the page upon loading, and use it in the HTML (as the product image) Add some jQuery plugin that handles the zoom on hover -
andy9l's post in Storing unknown amount of fields in db? was marked as the answerOne solution would be to store the input addresses to a PHP array, json_encode() the array, and store in a single 'addresses' column. You can then split this up again in a similar manner with json_decode().
$addresses = array(
array(
"line_1" => "1 My Street"
"line_2" => "",
"town" => "London",
"county" => "Surrey",
"post_code" => "LO12 3LO"
),
array(
"line_1" => "2 My Street"
"line_2" => "",
"town" => "London",
"county" => "Surrey",
"post_code" => "LO12 3LO"
),
array(
"line_1" => "3 My Street"
"line_2" => "",
"town" => "London",
"county" => "Surrey",
"post_code" => "LO12 3LO"
)
);
$encoded = json_encode($addresses);
//Store $encoded in 'addresses' column in tableEdit: But it would be better to implement rallport's suggestion - better database structure/normalisation.