|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
UPDATE query doesn't work
hi
When i click edit button, the script doesn't display any errors, it just does not apply any changes to the data in the selected row in the table, its probably some little bit is missing, but i just can't see it or my UPDATE query is not layered out correctly. [CODE] <?php $connection = mysql_connect("localhost", "root", ""); mysql_select_db("whitg22"); function deletenames() { $result = mysql_query("SELECT * FROM hits"); if (($row = mysql_fetch_array($result)) != 0) { echo "<table border=0>"; echo "<tr bgcolor=#cccccc> <td align=center>Title</td> <td align=center>Artist</td> <td align=center>Year</td> <td align=center>Genreid</td> <td align=center>Chart Position</td> <td align=center>Type</td> <td align=center>Price</td> <td align=center>Quantity</td> <td align=center>Choose a Hit</td> </tr>"; do { $title = $row['title']; $artist = $row['artist']; $year = $row['year']; $genreid = $row['genreid']; $chartposition = $row['chartposition']; $type = $row['type']; $price = $row['price']; $quantity = $row['quantity']; $id = $title; echo "<form method='post' action='change.php'> <tr> <td align='center'> <input type='text' name='title' value='" . $title . "' size='30' maxlength='30'></td> <td align='center'> <input type='text' name='artist' value='" . $artist . "'></td> <td align='center'> <input type='text' name='year' value='" . $year . "' size='4' maxlength='4'></td> <td align='center'> <input type='text' name='genreid' value='" . $genreid . "' size='5' maxlength='5'></td> <td align='center'> <input type='text' name='chartposition' value='" . $chartposition . "' size='10' maxlength='10'></td> <td align='center'> <input type='text' name='type' value='" . $type . "' size='5' maxlength='5'></td> <td align='center'> <input type='text' name='price' value='" . $price . "' size='4' maxlength='4'></td> <td align='center'> <input type='text' name='quantity' value='" . $quantity . "' size='5' maxlength='5'></td> <td align='center'> <input type='checkbox' name='id' value='" . $title . "'></td></tr>"; } while ($row = mysql_fetch_array($result)); echo "<tr><td><input type='submit' name='delete' value='Delete'>"; echo "<input type='submit' name='edit' value='Edit'></td></tr></table></form>"; } else { echo "No records found!"; } } deletenames(); if(isset($delete)) { mysql_query("DELETE FROM hits WHERE title = '$id'"); } if(isset($edit)) { mysql_query("UPDATE TABLE hits SET title = '$title', artist = '$artist', year = '$year', genreid = '$genreid', chartposition = '$chartposition', type = '$type', price = '$price', quantity = '$quantity' WHERE title = '$id'"); } ?> [CODE] |
|
#2
|
|||
|
|||
|
RE: UPDATE query doesn't work
Never mind, i found the error right after i posted the message, its not the first time it happened.
I deleted the word TABLE and it worked: UPDATE TABLE table SET .... |
|
#3
|
|||
|
|||
|
RE: UPDATE query doesn't work
Sorry, the code doesn't work properly. When i press the Update button wanting to change just one field in a row, it changes the whole row, replacing all the data in that row with the data from the row below. So, there are two rows with exactly the same data.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > UPDATE query doesn't work |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|