Jump to content


Minor Malfunction


1 reply to this topic

#1 Deathskin

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Gender:Male

Posted 28 January 2007 - 01:34 AM

The question is, when i press submit to UPDATE the artist, i have to press the Update button twice. I dont know why. Any help would be great.
Heres the code:

<html>
<title></title>
<head>


</head>
<body>
<?php
//connect to mysql database
require ($_SERVER["DOCUMENT_ROOT"]."/Config/music.php");
$connection = mysql_connect($db_host, $db_user, $db_pw) or die(mysql_error());
mysql_select_db($db_name, $connection);
?>

<!-- Add Song Form -->
<form action="<?php $_SERVER[PHP_SELF] ?>" method=post>
<input type="text" name="artist" maxlength="75" value="ARTIST">
<input type="text" name="song" maxlength="75" value="SONG">
<input type="text" name="rating" maxlength="3" size="1" value="%">
<input type="text" name="albumID" maxlength="4" size="1" value="ID">
<input type="submit" name="submit" value="send">
</form><br>
<!-- end of form -->

<?php

$sql = "INSERT INTO songs values('','$_POST[artist]','$_POST[song]', $_POST[rating], $_POST[albumID])";
if (MYSQL_QUERY($sql, $connection)){ echo "Record Added!";}
?>

<a href="display.php">Display songs</a>


<?php
// displays mysql table: songs...


$sql = mysql_query("SELECT * FROM songs") or die(mysql_error());

while ($songs = mysql_fetch_array($sql)){

$ID = $songs[id];
$ARTIST = $songs[artist];
$SONG = $songs[song];
$RATING = $songs[rating];
$ALBUMID = $songs[albumID];
echo "
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=1 BORDERCOLOR=#FFFFFF><TR>
<TD BGCOLOR=#F1F1F1 width=20>$ID
<TD BGCOLOR=#d5d5d5 width=150>$ARTIST
<TD BGCOLOR=#F1F1F1 width=150>$SONG
<TD BGCOLOR=#d5d5d5 width=25>$RATING
<TD BGCOLOR=#F1F1F1 width=25>$ALBUMID
</TD></TR><TABLE>";}
?>
<form action="<?php $_SERVER[PHP_SELF] ?>" method=post>
<input type="text" name="update_id" maxlength="3" size="1" ID>
<input type="text" name="update_artist" maxlength="75" value="ARTIST">
<input type="submit" name="update" value="UPDATE">
</form>

<?php
$update_artist = "UPDATE songs SET artist = '$_POST[update_artist]' where id = $_POST[update_id]";
mysql_query($update_artist);
?>


</body>

#2 Deathskin

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Gender:Male

Posted 28 January 2007 - 11:09 AM

thanks for the tips ill remember them :closedeyes: But, i still find myself clicking Update button twice to UPDATE the column :/ i dont know why this happens.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users