Hello, a noob in web programming here. Doing some course related database, would appreciate any help :), I want to ask whether any of you can help me on how to retrieve get data from mysql using php function, but separate each data from mysql one by one, cause i want the query done by my php function be a draggable object, my function look like this:

$sql_fundamental_g= "SELECT mf_mname, mfg_group_name, credits
FROM major_fundamental_g, major_fundamental, course, course_group
WHERE mf_mname =  '".$q."'
AND mfname = mfg_mfname
AND course_group_name = mfg_group_name
AND course_group_name = code";

$result = mysql_query($sql_fundamental_g);

echo "<b>Major Fundamental Courses</b><br>";

echo "<br><br>Student who major in ".$q." should take all of the following :<br>";

echo "<table border='1'>

while($row = mysql_fetch_array($result))
  echo "<tr>";
  echo "<td>" . $row['mf_mname'] . "</td>";
  echo "<td>" . $row['mfg_group_name'] . "</td>";
  echo "<td>" . $row['credits'] . "</td>";
  echo "</tr>";
echo "</table>";

and in this result i get the whole table, but i'm wondering if i can generate row by row ,cause i wanna use each row as separate entity and make them a draggable object using ajax later on
Thanks a lot :)

5 Years
Discussion Span
Last Post by confstu

mysql_fetch_array returns a row of the table in a form of an array. You actually are processing row by row already in the code:

while($row = mysql_fetch_array($result))

Within the above while loop you can do anything with the row or the fields of the row.

Can you please explain more in detail what you want to achieve (I hope I did not missunderstand your question).


Thx so much for the reply broj1, oh maybe i didn't give clear explanation before, you could take a look of my html code:


<script type="text/javascript">
function allowDrop(ev)

function drag(ev)

function drop(ev)
var data=ev.dataTransfer.getData("Text");

<script type="text/javascript">

// function to get course for major 
function CurrentSelections(str) 
if (str=="")
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200)




<div id="txtHint"  draggable="true" ondragstart="drag(event)" width="100" height="100" >imported course from database will be listed here...</div>


basically what i want to show in html is the "txtHint" and my function CurrentSelections(str) get the php file, and show all the table, because i am using another function to drag the table, when i execute the code i end up dragging the whole table, but what i wanted is to just drag one row of the data from the table.and i don't know how to do it. Thanks again for your reply


OK so you want to drag the rows of displayed html table. This is a Javascript job. Have you checked the link pritaeas sent in above post? I think this is the answer for you (have a look at the code in the browser - you will find the css and javascript you need).

Votes + Comments
thanks once again, i will see pritaeas link and try it
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.