kdub718 Posted September 19, 2006 Share Posted September 19, 2006 Well basically I have a schedule page. With Date, Event, Location, and Finish... I have it setup right now to where I can just delete the hole line... well I want to add an edit feature so I don't have to delete the entire line I can just edit each line to put a finishing place in or just edit the line in general incase I miss spell something or a date gets changed for an event... also is there a way to order the entries by date? right now I have to order them backwards to make the most recen events show up on top... but if a date changes I have to re-do the entire schedule... here is what I have... I'm really new to php and the whole database stuff... also what is the difference with php and asp? (that might be a little off subject but incase someone out there wants to give me some insight that would be great)this is my editevent page code:[code]<? include("../secure.php");?><?if (isset($delete)) @mysql_query ("DELETE FROM events WHERE id = '$delete'"); ?><center><table width=728 align=center border=0 cellspacing=1 cellpadding=3><tr align=center> <td width="140" bgcolor=silver><B><font size=1 face="verdana">DATE</b></td> <td width="133" bgcolor=silver><B><font size=1 face="verdana">EVENT</b></td> <td width="139" bgcolor=silver><B><font size=1 face="verdana">LOCATION</b></td> <td width="140" bgcolor=silver><B><font size=1 face="verdana">QUALIFIED</b></td> <td width="140" bgcolor=silver><B><font size=1 face="verdana">FINISH</b></td></tr><? $result = @mysql_query("SELECT * FROM events ORDER BY id DESC LIMIT 20"); while ( $row = mysql_fetch_array($result) ) { echo ( "<tr align=center> <td><B><font size=1 face=verdana>" . $row["date2"] . "</b></td> <td><B><font size=1 face=verdana>" . $row["event"] . "</b></td> <td><B><font size=1 face=verdana>" . $row["location"] . "</b></td> <td><B><font size=1 face=verdana>" . $row["qualified"] . "</b></td> <td><B><font size=1 face=verdana>" . $row["finish"] . "</b></td> <td><B><font size=1 face=verdana> <a href='$PHP_SELF?delete=$row[id]'>Delete</a></b></td></tr>" );}?></TD></TR></TABLE>[/code]this is my addevent page code:[code]<? include("../secure.php");?><? if (!isset($submitok)): ?><br><form method=post action="<?=$PHP_SELF?>"><table align=center border=0 cellspacing=0 cellpadding=3> <tr valign=top> <td colspan=2 align=middle bgcolor=silver width=100% height=10> <b><font face="verdana" color=black size=1>Add Event</font></b> </td> <tr valign=top> <td align=right> <font size=1 face="verdana"><b>Date:</b></font> </td> <td> <input name="date2" maxlength=100 size=25> </td> </tr> <tr valign=top> <td align=right> <font size=1 face="verdana"><b>Event:</b></font> </td> <td><input name="event" maxlength=100 size=25> </td> </tr><tr valign=top> <td align=right> <font size=1 face="verdana"><b>Location:</b></font> </td> <td><input name="location" maxlength=100 size=25> </td></tr><tr valign=top> <td align=right><font size="1" face="verdana"><b>Qualified:</b></font></td> <td><input name="qualified" maxlength="100" size="25" /></td></tr><tr valign=top> <td align=right><font size="1" face="verdana"><b>Finish:</b></font></td> <td><input name="finish" maxlength="100" size="25" /></td></tr> <tr> <td colspan=2 align=middle> <input type=submit name="submitok" value=" Add Event "> </td></tr></table></form><BR><BR><? else: $sql="INSERT INTO events SET date2='$date2', event='$event', location='$location' , qualified='$qualified' , finish='$finish'";?> <table width=350 align=center border=0 cellspacing=0 cellpadding=3> <tr valign=top> <td colspan=2 align=middle bgcolor=silver width=100% height=10> <b><font face="verdana" color=black size=1>Success</font></b> </td> <tr valign=top> <td><BR><center> <font size=1 face="verdana">Event Added successfully</font></center><BR> </td> </tr> <tr> <td colspan=2 align=middle> <form action=main.php><input type=submit value=" Thank You "></form> </td></tr></table>[/code]Thanks in advance, Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/ Share on other sites More sharing options...
kdub718 Posted September 20, 2006 Author Share Posted September 20, 2006 any more information needed? that I may be missing? Anyone that can help me out? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/#findComment-95045 Share on other sites More sharing options...
kdub718 Posted September 20, 2006 Author Share Posted September 20, 2006 please? anyone? Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/#findComment-95513 Share on other sites More sharing options...
kdub718 Posted September 21, 2006 Author Share Posted September 21, 2006 well since nobody here wants to help me can someone suggest a site where I can get some help? Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/#findComment-95871 Share on other sites More sharing options...
HuggieBear Posted September 21, 2006 Share Posted September 21, 2006 I'd say on your page that displays the event, add two buttons to the right of it, one to update the data and one to delete it, these call editevent.php with the id field.Then you have your editevent.php check which button was pressed, if it's delete then it it sends DELETE sql to the database and deletes the record based on id, if it's edit then it sends SELECT sql to the database based on id and selects the information from that record into a form. Once submitted, the form uses the UPDATE sql to change the record.As for the displaying your records by date, it's as simple as including ORDER BY date DESC in your display code.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/#findComment-95989 Share on other sites More sharing options...
kdub718 Posted September 21, 2006 Author Share Posted September 21, 2006 thanks for the response... I'm really green (noobie as my user title says) when it comes to php coding... I have tried so many different ways and it just doesn't seem to be working for me at all... could you possible give me an example? I'm a little confused... okay maybe a lot confused! LOL =) Thanks,KW Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/#findComment-96202 Share on other sites More sharing options...
kdub718 Posted September 22, 2006 Author Share Posted September 22, 2006 Is there a way I can just put an update button next to my delete button? My delete button works and it deletes all the fields for each event... but I just want to add the update button on there so I can update a finish ect. I have the update button showing and everything but when I type in something different in the field and hit update it doesn't update... but If I hit the delete button that works fine? so am I just missing something for the update so it will save the update to the row? does that make any sense?My updated editevent.php page code:[code]<? include("../secure.php");?><?if (isset($delete)) @mysql_query ("DELETE FROM events WHERE id = '$delete'"); ?><?if (isset($update)) @mysql_query ("UPDATE FROM events WHERE id = '$update'"); ?><center><table width=809 align=center border=0 cellspacing=1 cellpadding=3><tr align=center> <td width="177" bgcolor=silver><B><font size=1 face="verdana">DATE</b></td> <td width="216" bgcolor=silver><B><font size=1 face="verdana">EVENT</b></td> <td width="242" bgcolor=silver><B><font size=1 face="verdana">LOCATION</b></td> <td width="64" bgcolor=silver><B><font size=1 face="verdana">FINISH</b></td></tr><? $result = @mysql_query("SELECT * FROM events ORDER BY id DESC LIMIT 20"); while ( $row = mysql_fetch_array($result) ) { echo ( "<tr align=center> <td><input name=newsubject type=text maxlength=100 size=25 value='" . $row["date2"] . "'></td> <td><input name=newsubject type=text maxlength=100 size=25 value='" . $row["event"] . "'></td> <td><input name=newsubject type=text maxlength=100 size=25 value='" . $row["location"] . "'></td> <td><input name=newsubject type=text maxlength=100 size=25 value='" . $row["finish"] . "'></td> <td><B><font size=1 face=verdana> <a href='$PHP_SELF?delete=$row[id]'>Delete</a> <a href='$PHP_SELF?update=$row[id]'>Update</a></b></td></tr>" );}?></TD></TR></TABLE>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21332-i-need-a-little-help-with-an-edit-page-please/#findComment-96985 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.