digitalgod Posted July 11, 2006 Share Posted July 11, 2006 hey guys,what I'm basicly trying to do is populating a table with elements from one table and at the same time selecting the element that's in another table... don't know if that made sense but here's what I mean[code]<?php$result=mysql_query("SELECT * FROM events WHERE name='". $name ."'") or die(query_error());$row=mysql_fetch_array($result);$query=mysql_query("SELECT * FROM djs") or die(query_error());$data=mysql_fetch_array($query);$aDj = array();//putting in the array all of the names of the djs in the djs tablewhile ($data2 = mysql_fetch_array($query)) { array_push($aDj,$data2['name']);}?><select name="dj" id="dj"> <option>Choose one</option> <?php//populating the drop down with that array but selecting the dj that is in the table events foreach ($aDj as $val) { echo "<option value='$val'"; if ($val==$data['name']) { echo " selected"; } echo ">".$val; }?> </select>[/code]right now I have 2 names but for some reason it's only displaying the one that isn't in the events, can't figure out why. Quote Link to comment https://forums.phpfreaks.com/topic/14333-logic-problem/ Share on other sites More sharing options...
digitalgod Posted July 12, 2006 Author Share Posted July 12, 2006 anyone? I keep trying a lot of different things but I fear that my eyes are too tired and I'm getting lost in my own code Quote Link to comment https://forums.phpfreaks.com/topic/14333-logic-problem/#findComment-56547 Share on other sites More sharing options...
sasa Posted July 12, 2006 Share Posted July 12, 2006 Remove line [code]$data=mysql_fetch_array($query);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14333-logic-problem/#findComment-56830 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.