![]() |
php and mysql
i think it's a bit off topic here vut i guess i'll try..
hm... the situation is that im using mysql for the database... lets say i have a table... id name addr 1 xxx vvv 2 sss eee 3 qqq rrr now my web program uses to add edit and delete data in the database lets say that i have delete record 1 and insert a new record... id name addr 4 ooo ppp 2 sss eee 3 qqq rrr here is my code" mysql_connect('localhost','','') or die(mysql_error()); mysql_select_db('test') or die(mysql_error()); function delete() { } $sql=mysql_query("SELECT * FROM weh"); echo '<table cellpadding = 8 cellspacing = 0>'; while ($row=mysql_fetch_assoc($sql)) { echo'<tr> <td>'. $row['id'].' </td> <td>'. $row['name'].' </td> <td>'. $row['addr'].' </td> <td> <form> <input type = "button" value="delete" id = "" name="delete" style=" width:60 px;height:20px"onclick = ""/> </td> <td> <input type= "button" value="edit" id = "" name = "edit" style=" width:60 px;height:20px"onclick = ""/> </td> </form>'; $cdel=$cdel+1; $cedit=$cedit+1;} echo '</table>'; ?> got the problem up in the input button since i can't figure it out how to determine which data to delete... hope you understand my explanation thanx... |
i actually have the same question, your basically asking how php knows which record to delete from the database when you select it.
|
hm... i know what to delete but the problem is ho to determine it in that format since i can't name the cation button and they are only generated 1 by 1 by the looping structure,...
|
Quote:
hope its clear enough..good luck.. |
er... thats the problem...
coz in my statement i can't figure out what row to delete hehehe try reading my code... probably i just skipped and just need an answer for how can i assign the value of variable to a input in a form.. (is that possible..) i have tried making the statement like this... echo '<input type="hidden" value='{$val}' name="hide"/>'; but it returns an error message... thanx again your help is really appriciated |
PHP Code:
|
uh... btw
echo '<input type="hidden" value='{$val}' name="hide"/>'; how can i rephrase my statement to come up with something like this.. because this doesn't work.. and i would like to know ip there are any possible alternate solution for my statement.. |
Quote:
Code:
echo '<input type="checkbox" name="button_delete"/>'; |
| All times are GMT. The time now is 03:06 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0