Jump to content

ppwalks

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by ppwalks

  1. Hello, I was wondering if anyone could help solve this minor problem also, (sorry for interupting) I have an SQL statement as shown below; UPDATE cms SET metaName = '.$metaKey.', metaDesc = '.$metaDesc.' WHERE rowID = 1"; It updates the intended field when posted, but if a blank field is sent it overwrites the data with nothing, I want it so if blank basically do nothing and leave previous data in tact. Any help is much appreciated and thankyou for your time.
  2. Thankyou "JESIROSE" its working well, thankyou for the help I used "WHERE rowID = 1" and all is well, first i emptied the database and started again with your advise and worked well, so thankyou again. (Nice dog in the picture by the way)
  3. And appologies for the confusion, this is the code from my pc it does correlate correctly on the server.. And may i say thankyou so much for you help so far you have been fantastic....
  4. Not made the field yet i was just experimenting with the first 2, it is for a static page to literally input content from a user via a form and have it display on the page but got stuck at the multiple submission, how will the id help please?
  5. this is the table i created in notepad then executed it in phpMyAdmin CREATE TABLE cms ( rowID INT NOT NULL AUTO_INCREMENT, metaName VARCHAR(100) NOT NULL, metaDesc VARCHAR(200) NOT NULL, homeText VARCHAR(600) NOT NULL, aboutText VARCHAR(1000) NOT NULL, servicesText VARCHAR(1500) NOT NULL, PRIMARY KEY(rowID) )
  6. i get the update part of the query, its the "WHERE" section, if they are random from say 10 fields how would i implement the "WHERE" when not knowing what the previous attribute would be? Thankyou for your time, you have already been so much help!
  7. I have actually tried the update command and still gave me the same problem
  8. so how would i do that if you don't mind me asking?
  9. To easier explain I have a normal table is in MyISAM format with 4 fields, metaTag, metaDesc, pageTitle & pageContent each in there own column, i have placed a form on the back end of the website which has input fields to pass the value to each table row. A form example which is in its own include; <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"/> <label>Page Title</label><input type="text" id="meta-data" name="home_title"/> <span class="example">Example: Company Name LTd, "main Service"..</span> <label>Home Page Text</label><textarea class="body-text" name="home_text"></textarea><input type="submit" value="Update" id="home-update" name="home_update"/> </form> Then from the form it will send to database like so; if (isset($_POST['home_update'])) { mysql_select_db("barryjam_cms"); $sql="INSERT INTO cms (pageTitle, pageText) VALUES ('$_POST[home_title]', '$_POST[home_text]')"; if (!mysql_query($sql)) { $error =('Error: ' . mysql_error()); } else $result_home = "updated"; echo "<script>setTimeout(\"location.replace('control_panel.php')\",2000)</script>"; mysql_close(); } include ('inc/home_form.php'); As i mentioned this is only a simple bit of code, but when i submit say only page title in the form it will add to pageTitle in the database and leave the other column blank, so when the data is output to the page it will only display the most recent field. I want it so if the field is blank it will still use the previous data on the page. An easy solution would be to use multiple tables but at guess i would say that is extremely bad practice. Please remember i'm a student trying to learn php & Mysql so my terminolgy and knowledge may not be adequate. If you could point me in the right direction i would be ever so grateful and thankyou for your time. PS. i have not took any measures as yet to stop sql injections nor formatted the output string to be html compliant, this is just the foundation to my building blocks. If i'm going in the wrong direction can you please let me know also. Thankyou paul
  10. Hello, I am new to php programming and one obstacle has got me stuck now for several days and driving me insain, please if someone could point me in the right direction i would be ever so grateful. As part of a project at college I have been given an assignment to post data to sql database and then retrieve all the fields and output them to page, all is well up to now. i have made the form which successfully submits data to sql and i have been able to the echo the appropraite variables back to page. The problem I have is when I submit the form it sends all fields, if I wanted to only change 2 fields then it would overwrite the whole thing then display the 2 fields inserted only, i want it to display the data before the new row has NULL atributes in them. Please can somebody help! Thankyou Paul
×
×
  • 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.