Return data from database into textarea based on anchor link
Posted: Thu Jul 30, 2009 9:44 pm
Hi All,
I'm working on a recipe website and would like to have a feature where there is a food dictionary.
There are links from a to z at the top of a <textarea> object and would like to return data (MySQL as backend database) starting with the respective letter link that was clicked using the onClick method for the anchor tag into the <textarea> object.
Currently I have this code written has a test sample only for the letter "a":
The problems are:
The letter "a" anchor tag is returned x amount of times (which is not the point to have) with ingredients starting with "a" and when you click any of the sequential "a" anchor tags that respective ingredient displays in the <textarea> object with its definition.
I need all of the ingredients starting with the specific letter clicked displayed at once with its definition in the textarea.
I also need to figure out how to store what links were click into a php variable that will be used in the mysql_query instead of "LIKE 'a%'".
Any help would be very much appreciated.
recipeDev
I'm working on a recipe website and would like to have a feature where there is a food dictionary.
There are links from a to z at the top of a <textarea> object and would like to return data (MySQL as backend database) starting with the respective letter link that was clicked using the onClick method for the anchor tag into the <textarea> object.
Currently I have this code written has a test sample only for the letter "a":
The problems are:
The letter "a" anchor tag is returned x amount of times (which is not the point to have) with ingredients starting with "a" and when you click any of the sequential "a" anchor tags that respective ingredient displays in the <textarea> object with its definition.
I need all of the ingredients starting with the specific letter clicked displayed at once with its definition in the textarea.
I also need to figure out how to store what links were click into a php variable that will be used in the mysql_query instead of "LIKE 'a%'".
Any help would be very much appreciated.
recipeDev
Code: Select all
<form name="ingredient_list" id="ingredient_list" method="get">
<div class="FoodDictionaryList">
<?php
$q1=mysql_query("SELECT * FROM tblRTG_Ingredients WHERE Ingredient LIKE 'a%'");
while($row=mysql_fetch_array($q1))
echo('<a href="#ingredientDef" onclick="ingredient_list.ingredientDef.value=\'' . $row['Ingredient'] ."-". $row['Definition'] . '\';">a</a>'); ?> |
<a href="ingredientDictionary/b-ingredients.php">b</a> |
<a href="ingredientDictionary/c-ingredients.php">c</a> | <a href="ingredientDictionary/d-ingredients.php">d</a> |
<a href="ingredientDictionary/e-ingredients.php">e</a> | <a href="ingredientDictionary/f-ingredients.php">f</a> |
<a href="ingredientDictionary/g-ingredients.php">g</a> | <a href="ingredientDictionary/h-ingredients.php">h</a> |
<a href="ingredientDictionary/i-ingredients.php">i</a> | <a href="ingredientDictionary/j-ingredients.php">j</a> |
<a href="ingredientDictionary/k-ingredients.php">k</a> | <a href="ingredientDictionary/l-ingredients.php">l</a> |
<a href="ingredientDictionary/m-ingredients.php">m</a> | <a href="ingredientDictionary/n-ingredients.php">n</a> |
<a href="ingredientDictionary/o-ingredients.php">o</a> | <a href="ingredientDictionary/p-ingredients.php">p</a> |
<a href="ingredientDictionary/q-ingredients.php">q</a> | <a href="ingredientDictionary/r-ingredients.php">r</a> |
<a href="ingredientDictionary/s-ingredients.php">s</a> | <a href="ingredientDictionary/t-ingredients.php">t</a> |
<a href="ingredientDictionary/u-ingredients.php">u</a> | <a href="ingredientDictionary/v-ingredients.php">v</a> |
<a href="ingredientDictionary/w-ingredients.php">w</a> | <a href="ingredientDictionary/x-ingredients.php">x</a> |
<a href="ingredientDictionary/y-ingredients.php">y</a> | <a href="ingredientDictionary/z-ingredients.php">z</a>
<br/>
<textarea name="ingredientDef" rows="10" cols="60"/>
</textarea>
</div>
</form>
