fishbaitfood
Members-
Posts
97 -
Joined
-
Last visited
Never
Everything posted by fishbaitfood
-
Indeed.. Thanks a bunch ManiacDan!
-
Oh yeah, linking my tables with foreign keys isn't necessary for this. I need to dig in some more where using foreign keys is handy. Thanks for the JOIN query! Saved me severel rows of code!
-
Hmm, yeah, I know, but I'm having trouble linking my two tables in MySQL. It's causing me a lot of errors.
-
ManiacDan, ofcourse! Totally forgot about it, because I already have a loop for displaying the results. Sorry for starting this topic! Thanks again.
-
Hi there, I have this query, which outputs the records properly in PhpMyAdmin. But when using this query inside my PHP code, the result is incomplete. Instead of retrieving the expected 15 results, I only get the first one twice. Also, I don't get any errors. <?php $get_files = "SELECT `id` FROM `files` WHERE `category` = 'W';"; include_once('connection.inc.php'); $con = mysql_connect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD) or die ("Connection failed: " . mysql_error()); $dbname = "myDB"; $select_db = mysql_select_db($dbname, $con) or die ("Can't open database: " . mysql_error()); $result_files = mysql_query($get_files) or die ("Query failed: " . mysql_error()); $files = mysql_fetch_array($result_files); $W_files = "'".implode("', '", $files)."'"; // echo $W_files; outputs the first number twice, instead of the expected 15 different ones $get_checklist = "SELECT * FROM `checklist` WHERE `id` IN ($W_files) ORDER BY `id` ASC;"; $result_checklist = mysql_query($get_checklist) or die ("Query failed: " . mysql_error()); // .... code for displaying ?>
-
[jQuery] "Joining" two arrays with jQuery loop?
fishbaitfood replied to fishbaitfood's topic in Javascript Help
Thanks Adam, I can't believe I couldn't think of that myself! So obvious. Thanks for hinting that out. -
Hello there, I have two arrays with an equal amount of values. array fileList: names of files array file_numList: numbers of files I want those values to match their respective other, with a loop. Output would look something like this: for (var i = 0; i < fileList.length ; i++) { $("div.box").append("<input type=\"radio\" value=\""+file_numList[i]+"\" />"+fileList[i]); } This won't work however. And with an .each() loop, I can't seem to get an i counter? How would I do this?
-
Output dynamic array values in json array.
fishbaitfood replied to fishbaitfood's topic in PHP Coding Help
Indeed, forgot to apply the while loop. It works like a charm now! With jQeury $.each(data.files), I'm now able to generate my file radio button options. Thanks again, requinix! -
Output dynamic array values in json array.
fishbaitfood replied to fishbaitfood's topic in PHP Coding Help
Thanks, requinix, that did the trick! BUT, I can only receive ONE file, even when there are two, three, ... I did some debugging, and when I execute the query in MySQL itself, I'm able to receive multiple filenames, as expected to work. But when using the same query with PHP and using print_r, there's only ONE (the first) file in the array. $select_files = "SELECT file FROM files WHERE customer = '$customer';"; How's this possible? -
Output dynamic array values in json array.
fishbaitfood replied to fishbaitfood's topic in PHP Coding Help
Hmm, that would work, yes. My output would be something like this: output = array('customer' => $customer, 'address' => $address, '0' => file1, '1' => file2, '2' => file3, ...); My goal is, with jQuery, to loop through the FILES ONLY, and make them radio button options. Is this possible with the above output? Appreciate your help, many thanks! -
Output dynamic array values in json array.
fishbaitfood replied to fishbaitfood's topic in PHP Coding Help
Thanks for your fast answer requinix! How would I dynamically fetch those values with jQuery? Maybe I could count the array in jQuery, then subtract the amount of other (standard) values, to get the amount of dynamic values? Or is this much more easier to solve? Because I need to be able to put those values where I want them on my webpage. EDIT: with the above code, I get a syntax error, unexpected T_INC, expecting '}' on the line $output["fileName{$i++}"] = $files["fileName"]; -
Hello all, I have yet again trouble finding a logical solution to my problem. I'm fetching an array which can hold 1 or more values. The problem is, I want these values to ouput in my json_encode function, but this also needs to happen dynamically depending on the amount of values. I can't explain it further, so here's the code so far: $files = mysql_fetch_array($get_files); $a = count($files); $i = 1; while ($files) { $variablename = 'fileName' . $i; $$variablename = $files['fileName']; $i++; } $output = array( OTHER VALUES , 'fileName1' => $fileName1, 'fileName2' => $fileName2, 'fileName3' => $fileName3, ............); // How do I add the fileNames dynamically depending on how many there are? This got me thinking, I also need to dynamically GET the values with jQuery. How would I do that, when the above eventually works? Thank you.
-
Thanks for your help, but that only works for two button states as far as I know. The problem is, I have 4 button states. So I need to put 2 class names in each toggle function, which won't work (overrides?). Or am I missing something? The button states are: - unchecked - unchecked, highlighted (mousedown) - checked - checked, highlighted (mousedown)
-
Is there a way to get my 4 button states, according to mouseDown and Up, in each toggle function, to work in a .live('click') function instead? With toggle it's easy to have two functions, so I can have my 4 button states in it. But with a click function, I only have one function. How could I implement the toggle functionality with 4 button states in one click function? The toggle function in my first post works, but my button states only appear after the first click.
-
Uncaught TypeError: Cannot read property 'address' of null
fishbaitfood replied to fishbaitfood's topic in Javascript Help
Wow, another great, useful function I did not know about! Thanks! And damnit! It isn't available on my domain. So I guess I shall contact my domain's hosting service... -
Uncaught TypeError: Cannot read property 'address' of null
fishbaitfood replied to fishbaitfood's topic in Javascript Help
echo $output["address"]; Echoing out the different data works fine. It's just so weird I don't get an output when echoing json_encode($output); -
Uncaught TypeError: Cannot read property 'address' of null
fishbaitfood replied to fishbaitfood's topic in Javascript Help
Exactly.. that's why I'm here. It works perfectly on localhost. But somehow, on my domain, json_encode removes my data or something. -
Uncaught TypeError: Cannot read property 'address' of null
fishbaitfood replied to fishbaitfood's topic in Javascript Help
PHP version: 5.1.2 MySQL Character set: UTF-8 Unicode (utf8) And my database collation is also set to 'utf8_general_ci'. -
Uncaught TypeError: Cannot read property 'address' of null
fishbaitfood replied to fishbaitfood's topic in Javascript Help
With Firebug I get about the same error. Posting the customer to "get-customer-data.php" is OK. But with $.ajax success function, my $(".input-address").val(data.address); seems to be null. Firebug states: Data is null. $(".input-address").val(data.address); So from what I understand.. The array is present, so there IS data, but when json_encode comes in, $.ajax won't receive the data. -
Uncaught TypeError: Cannot read property 'address' of null
fishbaitfood replied to fishbaitfood's topic in Javascript Help
The data is present, but json_encode won't work. Adding the header information won't help either. This is what I get when I var_dump $output: array(3) { ["address"]=> string( "Broadway" ["city"]=> string( "New York" ["country"]=> string(13) "United States" } On localhost json_encode outputs {"address":"Broadway", "city":"New York", "country":"United States"}. But on my domain I just get a blank page when testing this.