PHP - Load Correct Cell On Edit
Hi, I have setup a little post function where you can edit it. When the data has been submitted it sends all data to a database.
When I go to edit a post this is how I have each dropdown to load the correct option:
<select name="ad_type"> <option selected="selected"><?php echo $post['ad_type']; ?></option> <option>-- Please Select --</option> <option value="For Adoption">For Adoption</option> <option value="For Sale">For Sale</option> </select>How would I do it so it would automatically select the correct option rather than having it add another option at the top? Thanks Similar TutorialsI HAVE TRIED looking at it but i am new to php so i can't figure out what i did wrong help please !!!!!!!!!!!! Fatal error: Call to undefined method modernCMS::update_form() in C:\wamp\www\test\inc\update-content.php on line 4 ---- Page that's accessing code ----- <?php include '../test/inc/admin/nav.php'; echo $obj->update_form($_GET['id']); ?> ------ function ------ <?php class modernCMS { var $host; var $username; var $password; var $db; function connect() { $con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error()); mysql_select_db($this->db, $con) or die(mysql_error()); } //end connect function get_content($id = '') { if($id != ""): $id = mysql_real_escape_string($id); $sql = "SELECT * FROM cms_content WHERE id = '$id'"; // $return = "<p><a href=../test/inc/admin/nav.php>Go Back To Content</a></p>"; else: $sql = "SELECT * FROM cms_content ORDER BY id DESC"; endif; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) != 0): while($row = mysql_fetch_assoc($res)) { echo '<table bgcolor="#975627" width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td height="25" background="images/menu.gif"><center><strong>' . $row['title'] . '</strong></center></td> </tr> <tr bgcolor="975627"><td height="0"></td></tr> <tr> <td bgcolor="#181818"> '; echo '<br> <div align="center">' . $row['body'] . ' <br><br> </td> </tr> <tr> <td height="25" background="images/menu.gif"> </td> </tr> </table><br><br> '; } else: echo '<p>Uh Oh!!! </p>'; endif; // echo $return; } //end get_content function add_content($p) { $title = mysql_real_escape_string($p['title']); $body = mysql_real_escape_string($p['body']); if(!$title || !$body): if(!$title): echo "<p>The title is required!</p>"; endif; if(!$body): echo "<p>The body is required!</p>"; endif; echo '<p><a href="add-content.php">Try Again!!!</a></p>'; else: $sql = "INSERT INTO cms_content VALUES (null, '$title', '$body')"; $res = mysql_query($sql) or die(mysql_error()); echo "Added Successfully!"; endif; } //end add_content function manage_content() { $sql = "SELECT * FROM cms_content ORDER BY id DESC"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)): ?> <div> <h2 class="title"><?php echo $row['title']; ?></h2> <span class="actions"<a href="../test/update-content.php?id=<?php echo $row['id']?>">Edit</a> | <a href="?delete= <?php echo $row['id'] ?> ">Delete</a></span> </div> <?php endwhile; echo '</div>'; //Class Manage Div } //end manage_content function delete_content($id) { if(!$id) { return false; }else { $id = mysql_real_escape_string($id); $sql = "DELETE FROM cms_content WHERE id = '$id'"; $res = mysql_query($sql) or die(mysql_error()); echo "Content Deleted Successfully!"; } } } //end delete_content function update_form($id) { $id = mysql_real_escape_string($id); $sql = "SELECT * FROM cms_content WHERE id = '$id'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); ?> <form method="post" action="./post-added.php"> <input type="hidden" name="update" value="true" /> <input type="hidden" name="id" value="<?php $row['id'] ?>" /> <div> <label for="title">Title:</label> <input type="text" name="title" id="title" value="<?php echo $row['title'] ?>" /> </div> <div> <label for="body">Body:</label> <textarea name="body" id="body" rows="8" cols="40" /><?php echo $row['body'] ?></textarea> </div> <input type="submit" name="submit" value="Update Content" /> </form> <?php } //end update_content_form function update_content($p) { $title = mysql_real_escape_string($p['title']); $body = mysql_real_escape_string($p['body']); $id = mysql_real_escape_string($p['id']); if(!$title || !$body): if(!$title): echo "<p>The title is required!</p>"; endif; if(!$body): echo "<p>The body is required!</p>"; endif; echo '<p><a href="update-content.php?id=' . $id . '">Try Again!!!</a></p>'; else: $sql = "UPDATE cms_content SET title = '$title', body = '$body' WHERE id = '$id'"; $res = mysql_query($sql) or die(mysql_error()); echo "Updated Successfully!"; endif; } //end update_content($p) ?> It's pretty simple to see what I am trying to do here. For some reason all results in the table are the same exact cityName replacing all existing records. The echoed results are correct. I've include a small dump of my table as well. $query = "SELECT cityName FROM sys_city_dev_2"; $resource = mysqli_query($cxn, $query) or die("MySQL error: " . mysqli_error($cxn) . "<hr>\nQuery: $query"); while($result = mysqli_fetch_assoc($resource)) { $nox = $result['cityName']; $toUpper = ucfirst($nox); echo "$toUpper" . "<br />"; $setString = "UPDATE sys_city_dev_2 SET cityName = '" . $toUpper ."' WHERE cityName != ''"; mysqli_query($cxn,$setString); } 100 Records of table dump (pre running my script above): -- -- Table structure for table `sys_city_dev_2_backup` -- CREATE TABLE IF NOT EXISTS `sys_city_dev_2_backup` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev_2_backup` -- INSERT INTO `sys_city_dev_2_backup` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'dothan', 0, 0, 0), (84011, 1, 'alabaster', 0, 0, 0), (84012, 1, 'birmingham', 0, 0, 0), (84013, 2, 'flagstaff', 0, 0, 0), (84014, 1, 'auburn', 0, 0, 0), (84015, 1, 'florence', 0, 0, 0), (84016, 1, 'gadsden', 0, 0, 0), (84017, 1, 'huntsville', 0, 0, 0), (84018, 1, 'mobile', 0, 0, 0), (84019, 1, 'montgomery', 0, 0, 0), (84020, 1, 'tuscaloosa', 0, 0, 0), (84021, 2, 'mohave valley', 0, 0, 0), (84022, 2, 'phoenix', 0, 0, 0), (84023, 2, 'prescott', 0, 0, 0), (84024, 2, 'sierra vista', 0, 0, 0), (84025, 2, 'tucson', 0, 0, 0), (84026, 2, 'yuma', 0, 0, 0), (84027, 3, 'bakersfield', 0, 0, 0), (84028, 3, 'chico', 0, 0, 0), (84029, 3, 'fresno / madera', 0, 0, 0), (84030, 3, 'gold country', 0, 0, 0), (84031, 3, 'humboldt county', 0, 0, 0), (84032, 3, 'imperial', 0, 0, 0), (84033, 3, 'inland empire', 0, 0, 0), (84034, 3, 'los angeles', 0, 0, 0), (84035, 3, 'alhambra', 0, 0, 0), (84036, 3, 'merced', 0, 0, 0), (84037, 49, 'fayetteville', 0, 0, 0), (84038, 49, 'fort smith', 0, 0, 0), (84039, 49, 'jonesboro', 0, 0, 0), (84040, 49, 'little rock', 0, 0, 0), (84041, 49, 'arkadelphia', 0, 0, 0), (84042, 49, 'texarkana', 0, 0, 0), (84043, 3, 'modesto', 0, 0, 0), (84044, 3, 'alta sierra', 0, 0, 0), (84045, 3, 'alpine', 0, 0, 0), (84046, 3, 'pedley', 0, 0, 0), (84047, 3, 'redding', 0, 0, 0), (84048, 3, 'alondra park', 0, 0, 0), (84049, 3, 'sacramento', 0, 0, 0), (84050, 4, 'canon city', 0, 0, 0), (84051, 3, 'san luis obispo', 0, 0, 0), (84052, 3, 'santa barbara', 0, 0, 0), (84053, 3, 'stockton', 0, 0, 0), (84054, 3, 'aliso viejo', 0, 0, 0), (84055, 3, 'visalia', 0, 0, 0), (84056, 3, 'yuba city', 0, 0, 0), (84057, 4, 'boulder', 0, 0, 0), (84058, 4, 'colorado springs', 0, 0, 0), (84059, 4, 'denver', 0, 0, 0), (84060, 4, 'applewood', 0, 0, 0), (84061, 4, 'pueblo', 0, 0, 0), (84062, 4, 'air force academy', 0, 0, 0), (84063, 5, 'avon', 0, 0, 0), (84064, 5, 'hartford', 0, 0, 0), (84065, 5, 'new haven', 0, 0, 0), (84066, 5, 'ansonia', 0, 0, 0), (84067, 5, 'fairfield', 0, 0, 0), (84068, 7, 'daytona beach', 0, 0, 0), (84069, 7, 'sebastian', 0, 0, 0), (84070, 5, 'wallingford center', 0, 0, 0), (84071, 8, 'belvedere park', 0, 0, 0), (84072, 7, 'sarasota springs', 0, 0, 0), (84073, 7, 'sandalfoot cove', 0, 0, 0), (84074, 7, 'san carlos park', 0, 0, 0), (84075, 7, 'st. augustine', 0, 0, 0), (84076, 7, 'tallahassee', 0, 0, 0), (84077, 7, 'safety harbor', 0, 0, 0), (84078, 7, 'ruskin', 0, 0, 0), (84079, 8, 'athens-clarke county', 0, 0, 0), (84080, 8, 'atlanta', 0, 0, 0), (84081, 8, 'augusta-richmond county', 0, 0, 0), (84082, 8, 'brunswick', 0, 0, 0), (84083, 8, 'columbus', 0, 0, 0), (84084, 8, 'americus', 0, 0, 0), (84085, 8, 'acworth', 0, 0, 0), (84086, 8, 'valdosta', 0, 0, 0), (84087, 10, 'boise', 0, 0, 0), (84088, 10, 'ammon', 0, 0, 0), (84089, 10, 'moscow', 0, 0, 0), (84090, 10, 'blackfoot', 0, 0, 0), (84091, 10, 'twin falls', 0, 0, 0), (84092, 10, 'meridian', 0, 0, 0), (84093, 10, 'jerome', 0, 0, 0), (84094, 10, 'idaho falls', 0, 0, 0), (84095, 11, 'addison', 0, 0, 0), (84096, 10, 'garden city', 0, 0, 0), (84097, 10, 'eagle', 0, 0, 0), (84098, 10, 'chubbuck', 0, 0, 0), (84099, 10, 'caldwell', 0, 0, 0), (84100, 12, 'bloomington', 0, 0, 0), (84101, 12, 'evansville', 0, 0, 0), (84102, 12, 'fort wayne', 0, 0, 0), (84103, 12, 'indianapolis', 0, 0, 0), (84104, 12, 'muncie / anderson', 0, 0, 0), (84105, 12, 'lafayette / west lafayette', 0, 0, 0), (84106, 12, 'south bend / michiana', 0, 0, 0), (84107, 12, 'terre haute', 0, 0, 0), (84108, 12, 'northwest indiana', 0, 0, 0), (84109, 13, 'ames', 0, 0, 0); I have learned php coding by doing (looking for patterns and trying things) and I have hit a roadblock trying to modify a template that creates a delimited text file of products from an ecommerce site (Sunshop) for upload to google base. I have tried to search for the answer but I don't know what I don't know so I may not have put the right search terms in. So I apologize if this has been addressed in the past. The script uses case to call up the contents of specific rows of the product table which I understand but in when I want to call up the manufacturer row Sunshop uses a reference number and then a different table called manufacturers with an ID row that matches the manufacturer row numbers (that are associated with each product) and then next to it a name row which contains the actual manuracturer names. Can I put code in the case that will pull up the referenced name as opposed to just the numbers that are in the column? This is what I have now that just calls up the cells from the manufacurer row: Code: [Select] case 'mfg': $item[mfg] = $item[manufacturer]; The mfg refers to this part of the code in an array: Code: [Select] array('header' => 'manufacturer', 'value' => 'mfg'), In case it helps I will attach the full document. Thanks. I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! I'm using php edit function to edit an php file online. I think the portion that writing the file is below. My issue is that wherever there's a quote ("), it's automatically adding a slash (\). For example, if I had class="abc", it changes to class=\"abc\". How do I fix this? Code: [Select] <?php $file = $_GET['f']; $script = $_POST['script']; if($file&&$script) { $fp=fopen($file, "w"); fwrite($fp,$script); fclose($fp); } ?> hello mates, I am needing help on editing a line in Flat File Database. I got it to pull the data i need out by using id but not sure on how i would go about getting it to update the FFD heres what i got so far $id2 = $_REQUEST['id']; $id = array(); $username = array(); $title = array(); $date = array(); $message = array(); $lines = file('../news/news.db'); foreach($lines as $line){ if($id != $id2) { $explode = explode("||",$line); $id = $explode[0]; $username = $explode[1]; $title = $explode[2]; $date = $explode[3]; $message = $explode[4]; } } ?> <form action="edit_news2.php?id=<?php echo $id; ?>" method="post" name="editnews"> <table width="100%"> <tr><td><input name="id" value="<?php echo "$id;" ?>" type="hidden" />UserName:</td><td> <input name="userName" value="<?php echo "$username" ?>" type="text" readonly="true" /></td></tr> <tr><td>News Title:</td><td> <input name="title" type="text" value="<?php echo "$title"; ?>" /></td></tr> <tr><td>Date/Time:</td><td> <input name="datetime" value="<?php echo "$date"; ?>" type="text" readonly="true" /></td></tr> <tr><td colspan="2">Message:</td></tr> <tr><td colspan="2"><textarea name="message" cols="50" rows="15"><?php echo "$message"; ?></textarea></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="submitBtn" value="Post News" /></td></tr> </table> </form> thank you Valkeri2010 Hi can anyone please help me, I have to create a edit page that retrieves information from a list so that a user can change the text. The page looks fine but when I enter data in the fields and update it leaves the page as it was retrieved. I am a beginner! My code looks like this: Code: [Select] <form method = "get" action = "edit.php"> <?php //check to see if user is logged on session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != "")) { header ("Location:login.php"); } include('connect.php'); //connection details to database in a connect.php page $product_id = $_GET['product_id']; $query = "SELECT * FROM products WHERE product_id = '$product_id'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ $product_id = $row['product_id']; echo "<table>"; echo "<tr>"; echo "<td><input name = 'product_id' type = 'hidden' value ='$row[product_id]'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Name:</td><td><input name = 'pname' type = 'text' value ='$row[product_name]'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Range:</td><td><input name = 'prange' type = 'text' value ='$row[product_range]'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Price:</td><td><input name = 'pprice' type = 'text' value ='$row[product_price]'></td>"; echo "</tr>"; echo "<tr>"; echo "<td><input type = 'submit' name = 'Submit' value = 'Update'></td>"; echo "</tr>"; echo "</table>"; } //if form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST'){ //get values from fields $productname = $_POST['pname']; $range = $_POST['prange']; $price1 = $_POST['pprice']; $price = (int)$price1; if ($productname == "" || $range == "" || $price == "" ) { $errorMessage .= "Please fill in all text boxes"; } else { $errorMessage = ""; } $query = "UPDATE products SET product_name = '$productname', product_range = '$range', product_price = '$price' WHERE product_id = '$product_id'"; $result = mysql_query($query); print "<br> $productname from range $range with a price of $price has been updated!"; } ?> Thank you in advance! hi...again got in a mess...i m developing this ticketing system where once i check the checkbox and press the edit button,it takes me to the edit page with the same ticket no to be printed there....how do i do this i have attached the two pages for your smooth understanding attachment 1-->page where i check the ticket no from a list of ticket nos attachment2-->page where the ticket no must be displayed as checked on the previous page help is appreciated in advance.... Hi I am trying to develop an editprofile.php page to allow users to change their details. So far i have written Code: [Select] <?php $result = mysql_query("SELECT username FROM users WHERE username = {$_SESSION['MM_Username']}"); $num_rows = mysql_num_rows($result); if($num_rows > 0) { while ($row = mysql_fetch_array($result)) { $username = $row['username']; } } ?> and then tried to test it by using Code: [Select] <div><?php echo $username ?></div> but nothing is being echo'ed out. What am i doing wrong? hi all, i have a page which lists all of my registered users from the mysql database but i want the ability to edit an account, here is my list users code (just shown the appropiate code and not the rest): Code: [Select] <?php require ('../secure/connect.php'); $sql = "SELECT * FROM users ORDER BY user_level ASC"; $result=mysql_query($sql); echo '<table width="80%" border="0" cellspacing="5" cellpadding="0">'; echo ' <tr> <th><p align="left">User ID:</th> <th><p align="left">User Level:</th> <th><p align="left">Username:</th> <th><p align="left">User Title:</th> <th><p align="left">Email:</th> <th><p align="left">Actions:</th> </tr>'; while($rows=mysql_fetch_array($result)){ ?> <tr> <td><?php echo $rows['userid']; ?></td> <td><?php echo $rows['user_level']; ?></td> <td><?php echo $rows['username']; ?></td> <td><?php echo $rows['user_title']; ?></td> <td><?php echo $rows['email']; ?></td> <td><a href="edit_account.php?id=">Edit Account</a></td> </tr> <?php } ?> this lists my users nicely, as you can see i put it a edit account action at the end with a empty id= because that may be a way of doing it but im not sure what else to do or if there is a better way of doing it. any help would be great! Hello people, well the question couldn't be more explicit. I just learned how to view the php.ini configuration of my server using the phpinfo()script. But apparently it is a read only file. So how does one edit it? I am trying to extend session timeout. Thanks. ok i want admin to click on the edit button and a form shows up where you can edit your events and stuff like that but i cant get the edit button to work Code: [Select] <?php require 'scripts/connect.php'; echo " <table width='472' border='0'> <tr> <th width='43' height='21' scope='col'>Event Id</th> <th width='116' scope='col'>Event Nane</th> <th width='106' scope='col'>Event Type</th> <th width='63' scope='col'>EDIT</th> <th width='63' scope='col'>DELETE</th> </tr> </table>"; $sqlCommand = "SELECT * FROM events"; $out = mysql_query($sqlCommand); while ($row = mysql_fetch_assoc($out)){ $eventid = $row["id"]; $eventname = $row["eventname"]; $eventtype = $row["typeevent"]; $eventinfo = $row["eventinfo"]; $date = $row["date"]; $time = $row["time"]; $livetickets = $row["sale"]; $numtickets = $row["numtickets"]; $pricestudents = $row["studentsprice"]; $priceseniors = $row["seniorsprice"]; $priceadults = $row["adultsprice"]; if ($_POST['editbtn']){ echo "<form action='editevent' method='post'> <table> <tr> <td>Event Name</td> <td></td> <tr> <tr> <td></td> <td></td> <tr> <tr> <td></td> <td></td> <tr> </table> </form> "; }else echo" <table width='472' border='0'> <tr><form action='editevent.php' method='post'> <th width='59' height='21' scope='col'>$eventid</th> <th width='159' scope='col'>$eventname</th> <th width='151' scope='col'>$eventtype</th> <th width='85' scope='col'><input type='button' name='editbtn' value='Edit' /></th> <th width='85' scope='col'><input type='button' name='deletebtn' value='Delete' /></th> </form></tr> </table>"; } ?> guys in this code i get some data from myswl table and i display them in to and html table with dynamic textboxes the first part works ok but how can i update the mysqltable with tha changes? i have try to work with one table and i get an error Notice: Undefined index: name1 in D:\....... <?php session_start(); include($_SERVER['DOCUMENT_ROOT'].'/includes/connection.php'); $result = mysql_query( "SELECT * FROM serv " ); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name1\" type=\"text\" value={$row['onoma-eponymo']} id=\"n1\" STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"25\" maxlength=\"24\" /></form></td>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name2\" type=\"text\" value={$row['username']} STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"7\" maxlength=\"5\" /></form></td>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name3\" type=\"text\" value={$row['password']} STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"7\" maxlength=\"5\" /></form></td>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name4\" type=\"text\" value={$row['serv_id']} STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"9\" maxlength=\"15\" /></form></td>"; echo "</tr>\n"; } echo "</table>"; if(isset($_POST['back'])) {header("location:admin.php");} if(isset($_POST['sub_update'])) { $text = $_POST["name1"]; mysql_query("INSERT INTO serv (password) VALUES ('$text') "); } ?> <body> <form method="post" action=""> <input type="Submit" name="sub_update" value="Ενημέρωση Αλλαγών"style="height:6em; width:16em; font-size:150%;"> <form method="post" action=""> <input type="Submit" name="back" value="Back"style="height:6em; width:16em; font-size:150%;"> </form> Hi, I hope this can be done and need some advise as to how. I have a search results page that has a URL of: results-page.php?make=FORD&model=TRANSIT--2000-on++Standard+LOW+ROOF+Models&submit.x=22&submit.y=7 Can i create a button or link on that page to adjust the start of the URL but keeping the dynamically created end part? i.e: new-results-page.php?make=FORD&model=TRANSIT--2000-on++Standard+LOW+ROOF+Models&submit.x=22&submit.y=7 I Hope this makes sense. Hi Guys, I have a list of branches in a database table with the following collumns, Ter BranchName BranchAddress BranchTel BranchEmail BranchLink Ter = Terriotory ID However every time i update a branch using the edit.php code it always sets the Ter as 1 again! Rather than leaving it the same. The actual field is read-only to prevent that from happening. It then always comes up with the error Duplicate entry '1' for key 1 but thats because there is already a branch with Ter=1 include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql = "UPDATE `ter` SET `Ter` = `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); echo (mysql_affected_rows()) ? "Edited Branch.<br />" : "Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); <form action='' method='POST'> <p><b>Territory:</b><br /><input name='Ter' type='text' value='<?= stripslashes($row['Ter']) ?>' size="3" readonly="readonly" /> <p><b>Branch Name:</b><br /><input name='BranchName' type='text' value='<?= stripslashes($row['BranchName']) ?>' size="50" /> <p><b>Address:</b><br /> <textarea name="BranchAddress" cols="40" rows="5"><?= stripslashes($row['BranchAddress']) ?></textarea> <p><b>Telephone:</b><br /><input name='BranchTel' type='text' value='<?= stripslashes($row['BranchTel']) ?>' size="15" /> <p><b>Email:</b><br /><input name='BranchEmail' type='text' value='<?= stripslashes($row['BranchEmail']) ?>' size="50" /> <p><b>Link:</b><br /><input name='BranchLink' type='text' value='<?= stripslashes($row['BranchLink']) ?>' size="50" /> <p><input type='submit' value='Save' /><input type='hidden' value='1' name='submitted' /> </form> <? } ?> Any Ideas? Cheers, S Hi all, I don't know if it is possible but i need to edit one word document, write the name of the customer in it, but at the right place and print it from a php form. The user write in that php form the customer id and if he exists, the system should modify the word template and print it. Do you think this is possible and if so how can i do that? Thanks in advance. Hugo hey guys i have an array but want to add "n." infront of each key value...example n.news_id, n.user_id etc...is there a simple way/function of doing it other than changing the values through a loop? Array ( [news] => Array ( => news_id [1] => user_id [2] => news [3] => date [4] => time ) ) ok I have text files with my logins to my emails and such.. Well I have this script to prepare the logins for another script the files with the logins are in this format email pass email pass email pass email pass $filename = 'text.txt'; $file = file($filename); $begin = "$"; foreach($file as $b){ list($email,$password) = explode(" ",$b); $emails[] = $begin."header[]=get_header('".$email."','".$password."');";} file_put_contents($filename,implode($emails)); echo "Text file edited"; sleep(5); Is what I am using to get the email and password in this format $header[]=get_header('email','pass'); but it is putting it like this $header[]=get_header('email','pass '); $header[]=get_header('email','pass '); $header[]=get_header('email','pass '); $header[]=get_header('email','pass '); $header[]=get_header('email','pass Why is it putting '); on a new line? I need it to be right behind the password so it looks like this $header[]=get_header('email','pass'); $header[]=get_header('email','pass'); $header[]=get_header('email','pass'); $header[]=get_header('email','pass'); $header[]=get_header('email','pass'); any ideas? Thanks Hi. I am working on a website that has restriction level. An admin, a staff, and ordinary user. In my admin page when I click the button "View Users" it shows all the listed users in a table, from admin to ordinary users. And on each entry is an option to either "Delete" or "Edit" the users account. Now I have a problem with editing user profile because it appears blank fields. Not like in the admin side wherein if I click "Edit" the fields are filled with the users info. How do I do this in the staff's page. Here is the view users code from the admin's page: Code: [Select] if (@$_GET['action'] == "View Users") { print "<font size=6 color=yellow><center>View User's Records</center><br></font>"; $result = mysql_query ("SELECT * FROM users order by user_lvl, lname asc"); $rows = mysql_num_rows($result); if ($rows!=0) { print "<table border=1 align=center cellspacing=10>"; print " <tr bgcolor=yellow align=center> <td>First Name</td> <td>Last Name</td> <td>Email</td> <td>Username</td> <td>Password</td> <td>Phone Number</td> <td>User Privilege</td> <td>Options</td> </tr>"; for ($i=0; $i< $rows; $i++) { $row = mysql_fetch_row ($result); print "<tr bgcolor= white align=center>"; print "<td>$row[0]</td>"; print "<td>$row[1]</td>"; print "<td>$row[2]</td>"; print "<td>$row[3]</td>"; print "<td>$row[4]</td>"; print "<td>$row[5]</td>"; print "<td>$row[6]</td>"; print "<td>[ <a href=admin_main.php?action=Delete&username=$row[3]>Delete</a> ]"; print "[ <a href=admin_main.php?action=Edit&username=$row[3]>Edit</a> ]"; print "</td>"; print "</tr>"; } print "</table>"; print "<font size=1 color=yellow>Number of entries found: $rows"; } else { print "No records found!"; } mysql_free_result ($result); } Now here is the code when I click "Edit" from the "View Users" table: Code: [Select] if (@$_GET['action'] == "Edit") { $result = mysql_query ("Select * from users where username='$_GET[username]'"); $row = mysql_fetch_row ($result); print "<font size=6 color=yellow><center>Edit Records </center></font>"; print "<form method = get> <table border = 1 align=center> <tr> <td><font color=yellow>First Name:</font></td> <td><input type=text name=fname value=$row[0] ></td></tr> <tr> <td><font color=yellow>Last Name:</font></td> <td><input type=text name=lname value=$row[1]></td></tr> <tr> <td><font color=yellow>Email Address: </font></td> <td><input type=text name=email value=$row[2] </td></tr> <tr> <td><font color=yellow>Username: </font></td> <td><input type = text name = username value=$row[3] ></td></tr> <tr> <td><font color=yellow>Password:</font></td> <td><input type=text name=password value=$row[4]></td></tr> <tr> <td><font color=yellow>Contact Number:</font></td> <td><input type = text name = phone_number value=$row[5]></td></tr> <tr> <td><font color=yellow>User Privilege:</font></td> <td><input type = txt name = user_lvl value=$row[6]></td></tr> <tr><td><input type=submit value='Update Users' Submit name=action></td></tr> </table> </form> "; } if (@$_GET['action']=="Update Users") { $result = mysql_query ("UPDATE users SET fname='$_GET[fname]', lname='$_GET[lname]', email='$_GET[email]', username='$_GET[username]', password='$_GET[password]', phone_number='$_GET[phone_number]', user_lvl='$_GET[user_lvl]' where username= '$_GET[username]'"); print "<font size=6 color=yellow><center><blink>Record of User successfully updated!</blink></center></font>"; } Hello I work on my school project where we have to create a website with front and back end. So I decided to create a lyrics website. I created a DB, with a table table called "lyrics" This is the structu CREATE TABLE lyrics ( lyricsId int(8) PRIMARY KEY AUTO_INCREMENT, artist varchar(100), song varchar(100), cover varchar(100), lyrics varchar(9999), chartId int(8), commentId int(8), FOREIGN KEY (chartId) REFERENCES charts(chartId), ); So right now I dont know how I can create a Editlyrics.php button where I can edit he lyrics by the ID page for example I have 2 sogns with lyrics and when i press on a song i go to the lyris of that song, and on that page I want to have a button where i can edit the lyrics. Tjis is what i did: I created a editlyrics.php file and added this code, but its not working and I know for a fact that nothing is right here, there are so many errors, but I dont know what the errors are or how can i fix this... <?php session_start(); include("connectdb.php"); $id = $_SESSION['id']; $lyricsId = $_POST['lyricsId']; $col = "UNDEFINED"; if(isset($_POST['lyricsId'])){ $col = "lyrics"; $val = $_POST['lyrics']; } $query = "UPDATE lyrics SET $col='$val' WHERE lyricsId=$id;"; if(mysqli_query($dbc_form,$query)){ header("Location: index.php"); }else{ $_SESSION['error_msg'] = "Same Lyrics!"; header("Location: index.php"); } ?> Any help? thanks |