PoH Posted December 4, 2009 Share Posted December 4, 2009 Hello PhPFreakes, Well today I was coding my Server Status list (http://rspsdefero.com/status) and I wanted to add a "edit" page, but I couldn't find out how after heaps of attempts. May someone please reply, or PM or email me if they think or know they can add it and I will send them the script. Thanks, Rspsdefero.com Staff. Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/ Share on other sites More sharing options...
trq Posted December 4, 2009 Share Posted December 4, 2009 May someone please reply, or PM or email me if they think or know they can add it and I will send them the script. That isn't how help forums work. Post your problematic code and a description of your problem. Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/#findComment-971640 Share on other sites More sharing options...
PoH Posted December 4, 2009 Author Share Posted December 4, 2009 Ok, updating my post now. Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/#findComment-971645 Share on other sites More sharing options...
PoH Posted December 5, 2009 Author Share Posted December 5, 2009 Here is my index.php: <? include "stat_conf.php"; ?> <html> <head> <title>Rspsdefero - A Runescape Private Server Community</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" media="screen" type="text/css" title="Style" href="css/style.css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> <script src="./js/application.js" type="text/javascript" charset="utf-8"></script> </head> <body bgcolor="#880000" text="#000000" link="#000000" vlink="#000000" alink="#000000"> <center><br> <? if($_GET['t'] == 'serv') { $serverid="{$_GET['hd']}"; $list_q = mysql_query("SELECT * FROM serverlist WHERE id='$serverid'") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { if($C_Settings['update'] == 1) { $ss = @fsockopen($list_f['serverhost'], $list_f['serverport'], $errno, $errstr, 2); if (!$ss) { $list_f['failed'] = $list_f['failed'] + 1; $list_f['status'] = 0; }else{ stream_set_timeout($ss, 2); $list_f['status'] = 1; @fclose($ss); } $list_f['checks'] = $list_f['checks'] +1; mysql_query("UPDATE serverlist SET checks=" . $list_f['checks'] . ", failed=" . $list_f['failed'] . ", status=" . $list_f['status'] . " WHERE id=" . $list_f['id'] . " LIMIT 1") or die (mysql_error()); } ?> <table width="70%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#333333"> <b><font size="3" face="Arial, Helvetica, sans-serif"><br /><?=$list_f['servername'];?></font></b> <thread> <tr bordercolor="hh.png" class="tablee"> <th width="30%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Server Name</font></b></div></th> <th width="21%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">IP</font></b></div></th> <th width="11%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Port</font></b></div></th> <th width="11%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Uptime</font></b></div></th> <th width="14%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Added on</font></b></div></th> <th width="13%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Offline? Or Online?</font></b></div></th> </tr> </thread> <tr class="tablee"> <td width="30%"><font size="2" face="Arial, Helvetica, sans-serif"><b><?=$list_f['servername'];?></b></font></td> <td width="21%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['serverhost'];?></font></td> <td width="11%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['serverport'];?></font></td> <td width="11%"><font size="2" face="Arial, Helvetica, sans-serif"> <? $uptime_calc = $list_f['checks'] - $list_f['failed']; $uptime = round( ($uptime_calc/$list_f['checks'])*100, 0 ); echo $uptime; ?>%</font></th> <td width="14%"><font size="2" face="Arial, Helvetica, sans-serif"> <?=$list_f['added'];?></font></td> <td width="13%"><font size="2" face="Arial, Helvetica, sans-serif"> <div align="center"><? if($list_f['status'] == 0) { echo '<strong><font color="#FF0000"><b>Offline</b></font></strong>'; }else{ echo '<strong><font color="#008000"><b>Online</b></font></strong>'; } ?></div></font></td> </tr> <tr> <td colspan="6"></td> </tr> </table> <br /><br /><table> <thread> <th width="150%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Description</font></b></th></div> </thread> <tr class="tablee"> <th width="30%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['description'];?></font></th> </tr> <tr> <td colspan="6"></td> </tr> </table> <? } ?> <? }else{ ?> <? if($_GET['t'] == "del") { if(!empty($_POST['Submit'])) { if(!preg_match('/^[A-Za-z0-9-\s]{5,35}+$/',$_POST['servername'])) {$C_Error['servername'] = "Needs to be at least 5 to 35 characters long, a-Z 0-9 and - space allowed.";} if(!preg_match('/^[a-zA-Z0-9_-]+([\.]{1}[a-zA-Z0-9_-]+)*([\.]{1})[a-zA-Z]{2,4}$/',$_POST['serverhost'])) {$C_Error['serverhost'] = "";} if(!preg_match('/^[a-zA-Z0-9_-]{6,25}+$/',$_POST['password'])) {$C_Error['password'] = "Needs to be at least 6 to 25 characters long, a-Z 0-9 and - _ allowed.";} if(empty($C_Error) and !empty($_POST['Submit'])) { $del_q = mysql_query("SELECT servername FROM serverlist WHERE servername = '" . $_POST['servername'] . "' and serverhost = '" . $_POST['serverhost'] . "' and password = '" . md5($_POST['password']) . "' LIMIT 1") or die (mysql_error()); if(!mysql_num_rows($del_q)){ echo "Couldnt delete server, Wrong password?"; }else{ mysql_query("DELETE FROM serverlist WHERE servername = '" . $_POST['servername'] . "' and serverhost = '" . $_POST['serverhost'] . "' and password = '" . md5($_POST['password']) . "' LIMIT 1") or die (mysql_error()); echo "Server has been removed from list, click <a href='index.php'>here</a> to go back to the status page"; } } }else{ ?> <br> <form method="post" action="?t=del"> <table width="30%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#333333"> <thread><tr align="center" bgcolor="#666666"> <th colspan="2"><b><font size="3" face="Arial, Helvetica, sans-serif">Delete Server</font></b></th> </tr> <tr> <th bgcolor="#999999" width="33%"><font face="Arial, Helvetica, sans-serif"><b><font size="2">Server Name</font></b></font></th> <th bgcolor="#CCCCCC" width="67%"> <input type="text" name="servername" value="<?=$_POST['servername'];?>"> <?=$C_Error['servername'];?> </th> </tr> <tr> <th bgcolor="#999999" width="33%"><b><font size="2" face="Arial, Helvetica, sans-serif">Server IP</font></b></td=h> <th bgcolor="#CCCCCC" width="67%"> <input type="text" name="serverhost" value="<?=$_POST['serverhost'];?>"><?=" " . $C_Error['serverhost'];?> </th> </tr> <tr> <th bgcolor="#999999" width="33%"><b><font size="2" face="Arial, Helvetica, sans-serif">Password</font></b></th> <th bgcolor="#CCCCCC" width="67%"> <input type="password" name="password"> <?=$C_Error['password'];?> </th> </tr> <tr align="center"> <th colspan="2"> <input type="submit" name="Submit" value="Submit"> </th> </tr> </thread> </table> </form> <p> <? } }elseif($_GET['t'] == "add") { if(!empty($_POST['Submit'])){ if(!preg_match('/^[A-Za-z0-9-\s]{5,35}+$/',$_POST['servername'])){$C_Error['servername'] = "Needs to be at least 5 to 35 characters long, a-Z 0-9 and - space allowed.";} if($_POST['servername'] != trim($_POST['servername'])){ $_POST['servername'] = trim($_POST['servername']); $C_Error['servername'] = "Dont abuse spaces!"; } if(!preg_match('/^[0-9]{5,6}+$/',$_POST['serverport'])){$C_Error['serverport'] = "Needs to be at least 5 to 6 characters long, 0-9 allowed.";} if(!preg_match('/^[a-zA-Z0-9_-]{6,25}+$/',$_POST['password'])){$C_Error['password'] = "Needs to be at least 6 to 25 characters long, a-Z 0-9 and - _ allowed.";} if($_POST['password'] != $_POST['passwordconfirm']){$C_Error['passwordconfirm'] = "Please recheck your password.";} if(!$C_Error['servername']){ $name_q = mysql_query("SELECT servername FROM serverlist WHERE servername = '" . $_POST['servername'] . "' LIMIT 1") or die (mysql_error()); if(mysql_num_rows($name_q)){$C_Error['servername'] = "Already in use.";} } if(!$C_Error['serverhost']){ $host_q = mysql_query("SELECT serverhost FROM serverlist WHERE serverhost = '" . $_POST['serverhost'] . "' LIMIT 1") or die (mysql_error()); if(mysql_num_rows($host_q)){$C_Error['serverhost'] = "Already in use.";} } } if(empty($C_Error) and !empty($_POST['Submit'])) { $ss = @fsockopen($_POST['serverhost'], $_POST['serverport'], $errno, $errstr, 2); if (!$ss) { $C_Info['failed'] = 1; $C_Info['status'] = 0; }else{ $C_Info['failed'] = 0; $C_Info['status'] = 1; stream_set_timeout($ss, 2); @fclose($ss); mysql_query("INSERT INTO serverlist (servername,serverhost,serverport,added,password,description,status,failed,checks)VALUES('" . $_POST['servername'] . "','" . $_POST['serverhost'] . "','" . $_POST['serverport'] . "','" . date("Y-m-d") . "','" . md5($_POST['password']) . "','" . $_POST['description'] . "','" . $C_Info['status'] . "','" . $C_Info['failed'] . "','1')") or die (mysql_error()); echo "Your server was added,<br>"; if($C_Info['status'] == 0) { echo "But is offline at this time."; }else{ echo "And is online at this time.<br />"; echo "Click <a href='index.php'>here</a> to go back to the status page."; } } }else{ ?> </p> <form method="post" action="?t=add"> <table width="30%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#333333"> <thread> <tr align="center" bgcolor="#666666"> <th colspan="2"><b><font size="3" face="Arial, Helvetica, sans-serif">Add Server</font></b></th> </tr> <tr> <th bgcolor="#999999" width="33%"><font face="Arial, Helvetica, sans-serif"><b><font size="2">Server Name:</font></b></font></th> <th bgcolor="#CCCCCC" width="67%"> <input type="text" name="servername" value="<?=$_POST['servername'];?>"><?=$C_Error['servername'];?> </th> </tr> <tr> <th bgcolor="#999999" width="33%"><b><font size="2" face="Arial, Helvetica, sans-serif">Server IP:</font></b></th> <th bgcolor="#CCCCCC" width="67%"> <input type="text" name="serverhost" value="<?=$_POST['serverhost'];?>"><?=" " . $C_Error['serverhost'];?> </th> </tr> <tr> <th bgcolor="#999999" width="33%"><b><font size="2" face="Arial, Helvetica, sans-serif">Server Port:</font></b></th> <th bgcolor="#CCCCCC" width="67%"> <input type="text" name="serverport" value="<?=$_POST['serverport'];?>"><?=$C_Error['serverport'];?> </th> </tr> <tr> <th bgcolor="#999999" width="33%"><b><font size="2" face="Arial, Helvetica, sans-serif">Password:</font></b></th> <th bgcolor="#CCCCCC" width="67%"> <input type="password" name="password"><?=$C_Error['password'];?> </th> </tr> <tr> <th bgcolor="#999999" width="33%"><b><font size="2" face="Arial, Helvetica, sans-serif">Confirm Password:</font></b></th> <th bgcolor="#CCCCCC" width="67%"> <input type="password" name="passwordconfirm"><?=$C_Error['passwordconfirm'];?> </th> </tr> </table> <tr> <th bgcolor="#999999" width="2000%"><b><font size="2" face="Arial, Helvetica, sans-serif">Description:</font></b></th><br> <th bgcolor="#CCCCCC" width="2000%"> <td> <textarea class="editor" name="description" rows="12" cols="60" onselect="storeCaret(this);" value="<?=$_POST['description'];?>" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="2"> </textarea></td> </th> </tr><br> HTML code is allowed. For HTML codes, to help you please click <a href="http://rspsdefero.com/status/htmlcodes.php"><font color="#0000FF">here</font></a>.<br> <tr align="center"> <th colspan="2"> <input type="submit" name="Submit" value="Submit"> </th> </tr> </thread> </form> <p> <? } }else{ $r_settings = fopen($C_Settings['cache_file'],'r'); flock($r_settings, LOCK_EX) ; while ($info = fscanf ($r_settings, "%d\n")) { list ($lastcache) = $info; } flock($r_settings, LOCK_UN); fclose($r_settings); if(time() - $lastcache > $C_Settings['recache']) { echo ""; $C_Settings['update'] = 1; $source = fopen($C_Settings['cache_file'],'r+'); flock($source, LOCK_EX); $newcache = sprintf("%d\n",time()); rewind($source); ftruncate($source,0); fwrite($source, $newcache); flock($source, LOCK_UN); fclose($source); }else{ echo ""; } ?> <table class="tables" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#333333"> <b><font size="5" color="#FFD700" face="Arial, Helvetica, sans-serif"><img src="http://i48.tinypic.com/allu9k.png" /></font></b><br> For details on how to get your server sponsered please click here. <thread> <tr bordercolor="hh.png" bgcolor="#999999"> <th width="30%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Server Name</font></b></div></th> <th width="21%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">IP</font></b></div></th> <th width="11%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Port</font></b></div></th> <th width="11%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Uptime</font></b></div></th> <th width="14%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Added On</font></b></div></th> <th width="13%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Offline? Or Online?</font></b></div></th> </tr> </thread> <? $list_q = mysql_query("SELECT * FROM serverlist WHERE gserver='1' ORDER BY failed asc, added asc") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { if($C_Settings['update'] == 1) { $ss = @fsockopen($list_f['serverhost'], $list_f['serverport'], $errno, $errstr, 2); if (!$ss) { $list_f['failed'] = $list_f['failed'] + 1; $list_f['status'] = 0; }else{ stream_set_timeout($ss, 2); $list_f['status'] = 1; @fclose($ss); } $list_f['checks'] = $list_f['checks'] +1; mysql_query("UPDATE serverlist SET checks=" . $list_f['checks'] . ", failed=" . $list_f['failed'] . ", status=" . $list_f['status'] . " WHERE id=" . $list_f['id'] . " LIMIT 1") or die (mysql_error()); } ?> <tbody> <tr class="tablee"> <td width="30%"><font size="2" face="Arial, Helvetica, sans-serif"><b><a href="?t=serv&hd=<?=$list_f['id'];?>"><?=$list_f['servername'];?></a></b></font></td> <td width="21%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['serverhost'];?></font></td> <td width="11%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['serverport'];?></font></td> <td width="11%"><font size="2" face="Arial, Helvetica, sans-serif"> <? $uptime_calc = $list_f['checks'] - $list_f['failed']; $uptime = round( ($uptime_calc/$list_f['checks'])*100, 0 ); echo $uptime; ?>%</font></td> <td width="14%"><font size="2" face="Arial, Helvetica, sans-serif"> <?=$list_f['added'];?></font></td> <td width="13%"><font size="2" face="Arial, Helvetica, sans-serif"> <div align="center"><? if($list_f['status'] == 0) { echo '<strong><font color="#FF0000">Offline</font></strong>'; }else{ echo '<strong><font color="#008000">Online</font></strong>'; } ?></div></font></td> </tr> <tr bordercolor="hh.png" bgcolor="#999999"> <td width="30%" class="tablef"><div align="center"></div></td> <td width="21%" class="tablef"><div align="center"></div></td> <td width="11%" class="tablef"><div align="center"></div></td> <td width="11%" class="tablef"><div align="center"></div></td> <td width="14%" class="tablef"><div align="center"></div></td> <td width="13%" class="tablef"><div align="center"></div></td> </tr> </tbody> <? } ?> <tr> <td colspan="6"></td> </tr> </table> <br /> <table class="tables" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#333333"id="resultTable"> <b><font size="4" face="Arial, Helvetica, sans-serif"><br /><br /><b>Other Servers</b></font></b> <thread> <tr bordercolor="hh.png" bgcolor="#999999"> <th width="30%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Name</font></b></div></th> <th width="21%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">IP</font></b></div></th> <th width="11%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Port</font></b></div></th> <th width="11%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Uptime</font></b></div></th> <th width="14%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Added on</font></b></div></th> <th width="13%" class="tablef"><div align="center"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Offline? Or Online?</font></b></div></th> </tr> <tr bordercolor="hh.png" bgcolor="#999999"> <td width="30%" class="tablef"><div align="center"></div></td> <td width="21%" class="tablef"><div align="center"></div></td> <td width="11%" class="tablef"><div align="center"></div></td> <td width="11%" class="tablef"><div align="center"></div></td> <td width="14%" class="tablef"><div align="center"></div></td> <td width="13%" class="tablef"><div align="center"></div></td> </tr> <tr bordercolor="hh.png" bgcolor="#999999"> <td width="30%" class="tablef"><div align="center"></div></td> <td width="21%" class="tablef"><div align="center"></div></td> <td width="11%" class="tablef"><div align="center"></div></td> <td width="11%" class="tablef"><div align="center"></div></td> <td width="14%" class="tablef"><div align="center"></div></td> <td width="13%" class="tablef"><div align="center"></div></td> </tr> </thread> <? $list_q = mysql_query("SELECT * FROM serverlist WHERE gserver='0' ORDER BY failed asc, added asc, status desc") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { if($C_Settings['update'] == 1) { $ss = @fsockopen($list_f['serverhost'], $list_f['serverport'], $errno, $errstr, 2); if (!$ss) { $list_f['failed'] = $list_f['failed'] + 1; $list_f['status'] = 0; }else{ stream_set_timeout($ss, 2); $list_f['status'] = 1; @fclose($ss); } $list_f['checks'] = $list_f['checks'] +1; mysql_query("UPDATE serverlist SET checks=" . $list_f['checks'] . ", failed=" . $list_f['failed'] . ", status=" . $list_f['status'] . " WHERE id=" . $list_f['id'] . " LIMIT 1") or die (mysql_error()); } ?> <tbody> <tr class="tablee"> <td width="30%"><font size="2" face="Arial, Helvetica, sans-serif"><a href="?t=serv&hd=<?=$list_f['id'];?>"><?=$list_f['servername'];?></font></td> <td width="21%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['serverhost'];?></font></td> <td width="11%"><font size="2" face="Arial, Helvetica, sans-serif"><?=$list_f['serverport'];?></font></td> <td width="11%"><font size="2" face="Arial, Helvetica, sans-serif"> <? $uptime_calc = $list_f['checks'] - $list_f['failed']; $uptime = round( ($uptime_calc/$list_f['checks'])*100, 0 ); echo $uptime; ?>%</font></td> <td width="14%"><font size="2" face="Arial, Helvetica, sans-serif"> <?=$list_f['added'];?></font></td> <td width="13%"><font size="2" face="Arial, Helvetica, sans-serif"> <div align="center"><? if($list_f['status'] == 0) { echo '<strong><font color="#FF0000">Offline</font></strong>'; }else{ echo '<strong><font color="#008000">Online</font></strong>'; } ?></div></font></td> </tr></a> </tbody> <? } ?> <tr bgcolor="#666666"> <td colspan="6"><font size="1" face="Arial, Helvetica, sans-serif"></font></td> </tr> </table> <br><br> <table width="15%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#333333"> <thread> <tr> <th class="tablef" bgcolor="#666666" align="center"><b><font color="white" size="3" face="Arial, Helvetica, sans-serif">Register a Server</font></b></td> </tr> </thread> <tr> <td class="tablee" align="center"><font face="Arial, Helvetica, sans-serif" size="2"><a href="?t=add"><font color="black">Click Here</font></a></font></td> </tr> <thread> <tr> <th class="tablef" bgcolor="#666666" align="center"><b><font color="white" size="3" face="Arial, Helvetica, sans-serif">Delete Server</font></b></td> </tr> </thread> <tr> <td class="tablee" align="center"><font face="Arial, Helvetica, sans-serif" size="2"><a href="?t=del"><font color="#000000">Click Here</font></a></font></td> </tr> </table> <form action="#search" method="post"> <p> <input type="text" name="filter" value="Search Servers" id="filter" /> <input type="submit" name="submit" value="Search Servers" /> </p> </form> <? } ?><? } ?><br><br> <br> </div> </center> </body> </html> I want a page so once someone has posted a server they can later return to the status page and edit the details of it, eg: Name, Description and Host. Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/#findComment-971646 Share on other sites More sharing options...
mikesta707 Posted December 5, 2009 Share Posted December 5, 2009 well, first off there are code/php tags for posting code. Secondly, that is a huge amount of code that I am not going to read through. As far as editing goes though the general logic that you use is as follows You generate your list of the servers (simple select statement with whatever WHERE clauses you want) Now lets say we got the following results server1 server2 server3 Now, assuming each entry in the database has a unique identifier (usually as an integer primary key that is set to auto increment) we can use this "id", along with a get variable to post to a page. To explain further... Lets pretend that our while loop to generate the list of servers looked something like $query = mysql_query("SELECT * FROM table ..."); while($row = mysql_fetch_assoc($query)){ echo $row['server_name']; } and lets pretend we had a page to edit a specific entry (more on this later). Well, we would need a way to send which entry we want to edit. Well, using the unique identifier (which I shall refer to as id) we can send the id as a get variable to the edit page. All we would need to do is alter our while loop above to something like this $query = mysql_query("SELECT * FROM table ..."); while($row = mysql_fetch_assoc($query)){ echo '<a href="edit.php?id='.$row['id'].'">'.$row['server_name'].'</a>'; } Now, what this will do is create a link. Assuming the first row returned has an id of 5, and the server name is "my_server", the link would look like <a href="edit.php?id=5">my_server</a> the ?id=5 part basically creates a GET variable named id, and sets its value to 5. Now, on edit.php, we could access that variable doing something like $id = $_GET['id']; Now the rest is really up to you. Something really common is to create a form (with textboxes and stuff) and populate them with the values from the table. Your query could look something like $query = "SELECT * FROM table WHERE id=$id"; That would select the specific row we want to edit. We could use a mysql_fetch_XXX function to grab data from that result set, and populate a form with that. For example, say we had 1 field we wanted to edit, and it was the name. We could make a form and populate it with the data like so $result = mysql_query($query); $row = mysql_fetch_assoc($result);//no need for a loop since we get only 1 row $name = $row['name']; //echo the form echo '<form action="whatever" method="post">';//you could also use get as the method echo '<input type="text" value="'.$name.'" name="newName">'; echo '<input type="hidden" name="id" value="'.$id.'">';//remember our $id variable from above echo '<input type="submit" name="submit" value="submit" >'; Now, the reason I created that hidden field is so that on the page that the form above submits to, we have access to the $id variable we used to get the old information from the table. Now we could use a simple update statement on the next page $newName = $_POST['newName']; $id = $_POST['id']; $update = "UPDATE table set server_name = '$newName' WHERE id=$id"; mysql_query($update); Hope that helps get you started Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/#findComment-971660 Share on other sites More sharing options...
PoH Posted December 5, 2009 Author Share Posted December 5, 2009 Wow, that is confusing... Can someone please edit my code and put that in for me? It would mean a lot and who ever gets this working will get a sum of 5 - 10USD paid into their paypal. Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/#findComment-971667 Share on other sites More sharing options...
mikesta707 Posted December 5, 2009 Share Posted December 5, 2009 Oh, if you're looking to pay someone to do it you can post in the freelancing section Quote Link to comment https://forums.phpfreaks.com/topic/184039-server-status-list-how-to-edit-details/#findComment-971668 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.