Zepur Posted January 11, 2012 Share Posted January 11, 2012 Hi! I am trying to make this site (http://karbotelling.com/TEST/index.php), and because I don't know any PHP I always encounter new problems. Or rather I cant find the right solutions to the problems. The search field gets values from mysql-query, and outputs it like this: $querry = ("SELECT * FROM db WHERE ean LIKE '%$trimmed%' OR navn LIKE '%$trimmed%' ORDER BY navn ASC LIMIT 37"); $numresults=mysql_query($querry); $numrows=mysql_num_rows($numresults); if ($numrows == 0) { echo "Kunne dessverre ikke finne noe ved å søke på: " . $trimmed . "."; } else { // get results $bresult = mysql_query($querry) or die("Couldn't execfff query"); while ($brow= mysql_fetch_array($bresult)) { echo '<div id="mlist" style="width:672; padding-right:5px; align:left;"> <div id="bulk2" style="padding-bottom:3px"> <div id="mnavn" class="madd" style="width: 280px">'. $brow['navn'] . '<> <div id="mkcal" class="madd" style="width: 62px">'. (float)$brow['kcal'] . '<span id="mspan">kcal</span><> <div id="mkarb" class="madd" style="width: 65px">'. (float)$brow['karb'] . '<span id="mspan">g</span><> <div id="mprot" class="madd" style="width: 80px">'. (float)$brow['prot'] . '<span id="mspan">g</span><> <div id="mfett" class="madd" style="width: 60px">'. (float)$brow['fett'] . '<span id="mspan">g</span><> <div id="mean" class="madd" style="width: 125px">'.$brow['ean'].'</span><> <><>'; $lll['navn'][] = $brow['navn']; } // end while } I want to be able to click each .madd-class, to add the values from the divs into a new array. So I can call the array in a separate link. Its to make a meal, by selecting food you search. I'm sorry if this should be done with javascript /jQuery/ajax and/or something else, but as I said, I have no clue as what to use. And truly sorry if I posted this in the wrong section. Quote Link to comment https://forums.phpfreaks.com/topic/254832-sql-query-list-click-add-to-array/ Share on other sites More sharing options...
Zepur Posted January 12, 2012 Author Share Posted January 12, 2012 Forgot to rewrite the post, as I first posted this on the PHP-section, but fount out this requires more a JavaScript-solution. Polarbear with me :/ Quote Link to comment https://forums.phpfreaks.com/topic/254832-sql-query-list-click-add-to-array/#findComment-1306723 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.