
Eliasen
Members-
Posts
12 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Eliasen's Achievements

Newbie (1/5)
0
Reputation
-
Noted. Thanks again
-
Thank you very much , I will get started reading. Thanks!
-
Thank you very much for you reply! I am still very new at SQL/PHP, any chance you could elaborate on what you just said, as I have no idea how to do this. Yes I did think there had to be a better way than to build a very long query. Thanks again!
-
Sorry for the double post. The variables in the above example is the ingredients, and it check in the database what you can make with the ingredient combination. So like if the database I have looks like this: | Recipe Name | Ingredient_1 | Ingredient_2 | Ingredient_3 | ----------------------------------------------------------------------------- | Sample Cake | Banana | Orange | Apple | | Sample Cake | Orange | Apple | Banna | ----------------------------------------------------------------------------- the query should spit out both of them, even though the combination is not the same, but they both contain the same ingredients.
-
Thanks for the quick reply! However it won't do exactly what I am after, as I don't want the values to be used more than once for each combination, eg: $a = banana $b = apple $c = orange so if $row_1 = '$a', $row_2 and 3 may not be assigned $a, (not the value, but the variable, like if $b = banana, $b may be assigned to either row_2 or 3). Phew, I am not that good at explaining, however I hope I made somewhat sense heh. Thanks again!
-
Hi everyone! I am not sure if this is possible, but can you make a query where it checks for several combinations? Eg. instead of making a query like this: $value_a = 5; $value_b = 1; $value_c = 9; "SELECT * FROM table WHERE row_1 = '$value_a ' AND row_2 = '$value_b ' AND row_3 = '$value_c ' OR row_1 = '$value_c ' AND row_2 = '$value_a ' AND row_3 = '$value_b ' OR row_1 = '$value_b ' AND row_2 = '$value_c ' AND row_3 = '$value_a ' .... etc etc etc." Is there a way to do this in a more fancy, quicker way, instead of having to put in all the different combinations? I hope I made sense, else please let me know and I will try to elaborate. Thanks!
-
is it not something like: if (empty($_POST['title'])) { echo "<p>Please enter a title correctly<br />before you try submitting the form again.</p>\n"; die ( '<a href="pef.html">click here go back and try again</a>' ); echo $id;} i could be wrong. Edit: Right, didn't read the question properly.
-
Hi Everyone, I have this piece of code: $getinfo = mysql_query("SELECT * FROM animals WHERE type='reptile'") or die(mysql_error()); $numRowsAge = mysql_num_rows($getinfo); $age = mysql_fetch_assoc($getinfo); while($age) { foreach(???????){ $date1 = $age['birthdate']; $date2 = time(); $seconds_between = $date2 - $date1; $minutes_between = $seconds_between/60; $hours_between = $minutes_between/60; $days_between = $hours_between/24; if ($hours_between >= 15 && $age['lifecycle_stage'] == "egg"){ $animal = array(); $animal['lifecycle_stage'] = "Baby"; $animal['age_minutes'] = round($minutes_between,1); $animal['age_hours'] = round($hours_between,1); $animal['age_days'] = round($days_between,1); $ins = sql_update('items', $animal, $age['id']); mysql_query($ins); } elseif ($days_between >= 7 && $age['lifecycle_stage'] == "Baby"){ $animal = array(); $animal['lifecycle_stage'] = "Adult"; $animal['age_minutes'] = round($minutes_between,1); $animal['age_hours'] = round($hours_between,1); $animal['age_days'] = round($days_between,1); $ins = sql_update('items', $animal, $age['id']); mysql_query($ins); } elseif ($days_between >= $age['max_age']){ $del="DELETE FROM items WHERE id='$age[id]'"; $died = mysql_query($del); } else { $animal = array(); $animal['age_minutes'] = round($minutes_between,1); $animal['age_hours'] = round($hours_between,1); $animal['age_days'] = round($days_between,1); $ins = sql_update('items', $animal, $age['id']); mysql_query($ins); } } } I want to calculate the animals age, and put it into the database (Do not mind the sql_update script, it is custom and it works). Right now it only worked with the first row in the database, when I used: for($count = 1; $count <= $numRowsSnakes; $count++) { instead of the while and foreach. How do I run this for each of the animals in the database? I believe the problem is at the top bit (the while and foreach), but I couldn't find a solution or a way of doing this. The foreach has just been left as ?????, as I have no idea of what to do here. Anyone able to enlighten me on how to use the while/foreach to solve my problem? Thanks!!
-
Sorry for the double post, If i put all the items into one table, many of the items will have rows which they do not use, say I merge a "personal info" table and "cars" table, so the cars will have rows with "sex" "age" "zipcode" etc, and the personal info will have "Manufactura" "make" etc. Will this be a problem? or should I just ignore this and assign a default value like 0?
-
Yea I was thinking this as well.. maybe add all rows to one table and take the information with a regular query? Or is this a bad idea? Thank you all for your replies! I appreciate it!
-
Thanks for the quick reply! The problem is that the "items_stats" table, which looks like this: [id | items_id | stat | value], the "stat" and "value" can be anything i choose to put in it. eg. some entries might look like this: [id | items_id | stat | value] 1 | 1 | sex | male 2 | 1 | age | 18 3 | 2 | zip | 4000 4 | 2 | server | Dell the Stat and the value can be anything, so if I need to show the items stats where I want them to be shown eg.: <td>'. $data['name'] .'</td> <td>'. $data['sex'].'</td> <td>'. $datas['zip'] .'</td> <td>'. $data['server'] .'</td> how can I do this? because when I do a normal JOIN syntax query it It just spews out the information in random order or like this: sex, age, zip,server,male,18,4000,Dell
-
Hi everyone, My problem is, I have a Database with the tables called: Items Items_stats The Items table contains the standard values that apply to all items, like name, value, picture, etc. The Items_stats table contains the specific customer stats for the individual items, and looks like this: id | item_id | stat | value Here is my problem. Since the "stat" and "value" values can be anything, how can I make it so that checks: if the "stat" value is called "age", display the "value" value? I tried with the join syntax, but no luck. Hope you can help me. Sincerely (MySQL v: 5.5.8 - PHP v: 5.3.3 - Apache v: 2.2.17)