943,546 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3108
  • PHP RSS
Dec 25th, 2008
0

sql query into textarea

Expand Post »
hallo there.

i am new in programming so i ask for your understanding

i want to put the results from a sql query into a textarea. then i want to be able to pick one of the records of textarea and delete it (textarea and database). (i dont have to use textarea i just thouhgt it would be a good idea)

something is not right. this is my code

php Syntax (Toggle Plain Text)
  1. echo "<form method=post name=f2 action='dd-delete.php'>";
  2.  
  3. $qry="SELECT id, member, math, bathmos FROM bathmoi";
  4. echo '<textarea name="show" rows="20" cols="70" readonly="readonly">';
  5.  
  6. while($result = mysql_fetch_array($qry)) {
  7. echo "$result[id], $resuld[memeber], $result[mathima]";
  8. }
  9. echo "</textarea>";
  10.  
  11. echo "<input type=submit value=Submit>";
  12. echo "</form>";

i receive:
PHP Syntax (Toggle Plain Text)
  1. <br />
  2. <b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>C:\xampp\htdocs\admin\drop_down\dd.php</b> on line <b>118</b><br />

can u help me? what should i do to see the records and be able to pick one of then in order to delete it (from database and textarea)?
Last edited by peter_budo; Dec 29th, 2008 at 5:50 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dourvas is offline Offline
20 posts
since Dec 2008
Dec 25th, 2008
0

Re: sql query into textarea

$qry="SELECT id, member, math, bathmos FROM bathmoi";
$handle=mysql_query($qry);

echo '<textarea name="show" rows="20" cols="70" readonly="readonly">';


if(mysql_num_rows($handle) > 0)
{

  while($result = mysql_fetch_array($handle)) 
  {
    echo "$result[id], $resuld[memeber], $result[mathima]";
  }

}
echo "</textarea>";

also it is not a good practice to allow user to delete records through a text box, the possibilities of error will increase.
you can list result in tabular form and display a delete link in the last column of each record rows.
Last edited by manish.s; Dec 25th, 2008 at 2:34 pm.
Reputation Points: 10
Solved Threads: 5
Light Poster
manish.s is offline Offline
29 posts
since Dec 2008
Dec 29th, 2008
0

Re: sql query into textarea

Click to Expand / Collapse  Quote originally posted by dourvas ...
while($result = mysql_fetch_array($qry))
hi there,
you get error at this line becuase in mysql_fetch_array($result) function can takes only result variable which holds output generated by $result=mysql_query($qry);
hope you understand.
Now for deleting part ,me also suggest make table which contain each row returned by query and last column contains link which hold link of php processing page and primary key of that row in the form of querysting.
please check this Url
http://www.experts-exchange.com/Web_..._23328726.html
Hope this will help you.
Thanks & Regards
Dilip Kumar Vishwakarma
Last edited by dilipv; Dec 29th, 2008 at 2:46 am.
Reputation Points: 10
Solved Threads: 4
Light Poster
dilipv is offline Offline
30 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: connectivity problem
Next Thread in PHP Forum Timeline: Adding multiple images





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC