Jump to content

wlpywd

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wlpywd's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. isn't that what the <form action="update5.php" method="post"> is for? with update5.php posted above: $ud_id=$_POST['ud_id']; $ud_date=$_POST['ud_date']; $ud_name=$_POST['ud_name']; $ud_color=$_POST['ud_color']; $ud_discription=$_POST['ud_discription']; $query="UPDATE contacts SET date='$ud_date', name='$ud_name', color='$ud_color', discription='$ud_discription' WHERE id='$ud_id'"; mysql_query($query); echo "Record Updated"; mysql_close();
  2. i am looking over this code and i am confused... I can sorta follow what is suppose to happen, but will this pull each record from the table?? or is there nothing to update from this code? We eventually want, and tried to do at first, the 'update' button to appear in a separate column on the display table page, a page where we display the data from the database, but couldn't get it to work. This code was saved from our first attempt at doing that. As i look at it, i think the * was used so it would pull for all the entries, i'm not sure how it would work stand alone. Am i looking at this too long and confusing myself for no reason?? also, tried to replace * and id with an entry and still get the same line 16 error!
  3. fixed it and getting this error message: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /*************/update.php on line 16
  4. I've taken out the posting action to a separate file, update5.php: $ud_id=$_POST['ud_id']; $ud_date=$_POST['ud_date']; $ud_name=$_POST['ud_name']; $ud_color=$_POST['ud_color']; $ud_discription=$_POST['ud_discription']; $query="UPDATE contacts SET date='$ud_date', name='$ud_name', color='$ud_color', discription='$ud_discription' WHERE id='$ud_id'"; mysql_query($query); echo "Record Updated"; mysql_close(); and then the update.php file now looks like this with the html tags out of the middle of code, i think. Is this what it should look like? cuz it is still not working for me... i am getting an error "Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /*************/update.php on line 16" <? $id=$_GET['id']; $con = mysql_connect("********", "*****", "*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****", $con); $query=" SELECT * FROM usa WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $first=mysql_result($result,$i,"date"); $last=mysql_result($result,$i,"name"); $fax=mysql_result($result,$i,"color"); $email=mysql_result($result,$i,"discription"); ?> <form action="update5.php" method="post"> <input type="hidden" name="ud_id" value="<? echo $id; ?>"> Date: <input type="text" name="ud_date" value="<? echo $date; ?>"><br> Customer: <input type="text" name="ud_name" value="<? echo $name; ?>"><br> Color: <input type="text" name="ud_color" value="<? echo $color; ?>"><br> Discription: <input type="text" name="ud_discription" value="<? echo $discription; ?>"><br> <input type="Submit" value="Update"> </form> <? ++$i; } ?>
  5. OK, i guess i need to post code in my question? couldn't quite figure out the other way we were trying, so now trying to have an update page for entries in our database. Putting together bits and pieces of knowledge and sample code, we are left with something that was working and as we've evolved it, its not working. Can anyone help and see somthing thats wrong? Thank you, $id=$_GET['id']; $con = mysql_connect("********", "*****", "*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****", $con); $query=" SELECT * FROM usa WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $first=mysql_result($result,$i,"date"); $last=mysql_result($result,$i,"name"); $fax=mysql_result($result,$i,"color"); $email=mysql_result($result,$i,"discription"); <form method="post"> <input type="hidden" name="ud_id" value="<? echo $id; ?>"> Date: <input type="text" name="ud_date" value="<? echo $date; ?>"><br> Customer: <input type="text" name="ud_name" value="<? echo $name; ?>"><br> Color: <input type="text" name="ud_color" value="<? echo $color; ?>"><br> Discription: <input type="text" name="ud_discription" value="<? echo $discription; ?>"><br> <input type="Submit" value="Update"> </form> $ud_id=$_POST['ud_id']; $ud_date=$_POST['ud_date']; $ud_name=$_POST['ud_name']; $ud_color=$_POST['ud_color']; $ud_discription=$_POST['ud_discription']; $query="UPDATE contacts SET date='$ud_date', name='$ud_name', color='$ud_color', discription='$ud_discription' WHERE id='$ud_id'"; mysql_query($query); echo "Record Updated"; mysql_close(); ++$i; }
  6. I am trying to do things step by step so i do not get confused or loose where i am. I want a simple table display of info entered into a database. I am right now trying to get update buttons in a column in my table. Here is what i'm doing. 1. form to insert data into a mysql database -- done 2. make insert.php file to handle posting form data - done 3. make a dynamic table to display info from the database --done 4. make an update.php file to handle posting updates to records -- done 5. make an update button at the end of each row in my table, in a new column-- that will update that row of data --??? stuck!! I think i can make a separate page thats a form that will update a record, but for some reason i can't get this to display for each record in its own column in a dynamic table display page. (1)First i would like to get the 'update' button to work for each row, then (2)i would like to change 1 text area of data from that row's 6 or so data fields so that instead of replacing the original data, like the other 5 records, it would just add to data originally entered in that text area. Is that possible? (3)Then i would like to ajax my table display page so when you hit 'update' button at the end of each row, it either changes that row into a form to update or 'expand down' a form for each row to update the data. Are these 3 steps also seeming correct to you, or will i need to do 2 or more of these at the same time to not make it more difficult for myself? So, i'm asking how can i make an update button display in a new column of data for each row displayed from mysql database? and then are my next two steps in creating this page logical or am i making something too difficult? thank you anyone!! I am a newbie, but trying very hard and so far i think doing ok entering data and displaying it in a dynamic table!
  7. I am having i think the same problem, and trying not to start new topics on same posts.  I have a form inserting data into a mysql database, and on the page where i call the data, a simple tabled list of the data displayed, anything entered in the "textarea" box is displayed as one long sentence instead of displaying where someone typed 'enter' key.  So display is like this: Jon Smith 554 main Anytown USA  instead of: Jon Smith 554 main Anytown USA I have tried adding this code, with the space taken out, to my code but it does not seem to work.  Is there more to it i need to do rather than whats shown here on my display page to get it to work correctly?  (i am fairly new to php...) thanks anyone!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.