Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-07-2009, 02:57 PM Update for every id
Super Talker

Posts: 115
Name: Not Telling
Trades: 0
I currently got this code, it updates the database when a form is submitted. It currently updates the row id 3 with this code:

PHP Code:
$id 3
and
PHP Code:
   WHERE `id` = '".$id."' 
How do I do it so it automatically picks every single row that's there?

PHP Code:
<?php
if (isset ($_POST['submit'])) // if the form was submitted, display their name
{
require_once (
'inc/config.php');
$title mysql_real_escape_string ($_POST['title']);
$url mysql_real_escape_string ($_POST['url']);

$mainnewstitle mysql_real_escape_string ($_POST['mainnewstitle']);
$mainnewsdate mysql_real_escape_string ($_POST['mainnewsdate']);
$mainnewsimage mysql_real_escape_string ($_POST['mainnewsimage']);
$mainnewsmessage mysql_real_escape_string ($_POST['mainnewsmessage']);
$mainnewslink mysql_real_escape_string ($_POST['mainnewslink']);

$firstnewstitle mysql_real_escape_string ($_POST['firstnewstitle']);
$firstnewsdate mysql_real_escape_string ($_POST['firstnewsdate']);
$firstnewsmessage mysql_real_escape_string ($_POST['firstnewsmessage']);

$secondnewstitle mysql_real_escape_string ($_POST['secondnewstitle']);
$secondnewsdate mysql_real_escape_string ($_POST['secondnewsdate']);
$secondnewsmessage mysql_real_escape_string ($_POST['secondnewsmessage']);

$thirdnewstitle mysql_real_escape_string ($_POST['thirdnewstitle']);
$thirdnewsdate mysql_real_escape_string ($_POST['thirdnewsdate']);
$thirdnewsmessage mysql_real_escape_string ($_POST['thirdnewsmessage']);

$id 3;  
$sql mysql_query ("
   UPDATE `news` SET 
      `title` = '"
.$title."', 
      `url` = '"
.$url."',
 
      `mainnewstitle` = '"
.$mainnewstitle."',
      `mainnewsdate` = '"
.$mainnewsdate."',
      `mainnewsimage` = '"
.$mainnewsimage."',
      `mainnewsmessage` = '"
.$mainnewsmessage."',
      `mainnewslink` = '"
.$mainnewslink."',

      `firstnewstitle` = '"
.$firstnewstitle."',
      `firstnewsmessage` = '"
.$firstnewsmessage."',  
      `firstnewsdate` = '"
.$firstnewsdate."',
      
      `secondnewstitle` = '"
.$secondnewstitle."',
      `secondnewsmessage` = '"
.$secondnewsmessage."',      
      `secondnewsdate` = '"
.$secondnewsdate."',      

      `thirdnewstitle` = '"
.$thirdnewstitle."',
      `thirdnewsmessage` = '"
.$thirdnewsmessage."',
      `thirdnewsdate` = '"
.$thirdnewsdate."'    
   WHERE `id` = '"
.$id."'
"
)
OR die (
mysql_error());
echo 
"Your website news have been updated. <hr>";
}

require_once (
'inc/config.php');
$query "SELECT * FROM `news`";
$result mysql_query($query) or die(mysql_error());
while (
$row mysql_fetch_array ($result))
{
?>
__________________
MY MSN:
Please login or register to view this content. Registration is FREE

PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
PM me anytime for HTML, PHP or web design help. I will be glad to help you out.
sith717 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-07-2009, 04:39 PM Re: Update for every id
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
leave off the where clause and every single row will be updated. They will of course all be identical, but if that's what you need, it will do that.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Update for every id
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32123 seconds with 12 queries