Poddy Posted June 21, 2008 Share Posted June 21, 2008 i have the following code: if ($bd == null) { $sql = "select * from `data` where `name` LIKE '$name' AND `spot` LIKE '$line' AND `piret` LIKE '$piret' "; $result = mysql_query($sql) or die ('blah balh' . mysql_error()); $numrows = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { $timestamp = $row['timestamp']; $line = $row['spot']; $piret = $row['piret']; $name = $row['name']; $comment = $row['text']; /* $takeoff = $row['takeoff']; $cockpit = $row['cockpit']; $appear = $row['appear']; $take += $takeoff; $cock += $cockpit; $appe += $appear; */ echo " <table width='200' border='1'> <tr> <td> $timestamp </td> <td> $name </td> </tr> <tr> <td rowspan='2'> $comment </td> <td> פירט: $piret </td> </tr> <tr> <td> ליין: $line </td> </tr>"; $sql = "select `short` from `questions`"; $result = mysql_query($sql) or die ('error' . mysql_error()); while ($row = mysql_fetch_assoc($result)) { $short = $row['short']; qvalues($short); } echo " </table> "; } } function code: function qvalues ($var) { $sql = "SELECT * FROM `data` where `$var` LIKE '%'"; $result = mysql_query($sql) or die ('error' . mysql_error()); $row = mysql_fetch_assoc($result); $points = $row["$var"]; $sql = "select `text` FROM `questions` where `short`='$var'"; $result = mysql_query($sql) or die ('error' . mysql_error()); $row = mysql_fetch_assoc($result); $text = $row['text']; echo "<tr><td> $points </td> <td> $text </td></tr>"; } this code generates a table with a name, timestamp, comment, piret and spot aswell as the score points this worked fine until now, but i needed to be able to add dynamically questions to the database so the table needed to be a bit more dynamic as well, i created the function to retrieve the data i need... it works however as of the change for the function the while($row = mysql_fetch_assoc($result)) only shows me 1 table, aka giving the script only 1 row... any help is appreciated Quote Link to comment Share on other sites More sharing options...
Poddy Posted June 21, 2008 Author Share Posted June 21, 2008 had a couple of $result variables redefining inside the loops.. just had to change their names topic solved Quote Link to comment 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.