Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 28th, 2004, 03:38 PM
shnackattack shnackattack is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 60 shnackattack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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]

Reply With Quote
  #2  
Old March 28th, 2004, 03:53 PM
shnackattack shnackattack is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 60 shnackattack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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 ....

Reply With Quote
  #3  
Old March 28th, 2004, 04:17 PM
shnackattack shnackattack is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 60 shnackattack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > UPDATE query doesn't work


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT