Jump to content

[SOLVED] Repopulating data


joeysarsenal

Recommended Posts

at the moment i have this

<?php		/* Populate The products Table 
	** Use an Include file to open the database
	*/

    include( "connect.inc" );


$sql =  "INSERT INTO tbl_product VALUES " .
"(0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', ''), " .
"(0, 16, 'Abu Garcia Cardinal CSW173 Fishing Reel', 'A fis4hing rod !!!!!!!!!', '62.95', '1000', '','', '', '')";




if(mysql_query($sql)){
  echo("<p>Product table successfully populated!</p>");	
}
else{
  print("<p>Error adding to Product table: " . mysql_error() . "</p>");	
}
?>

and im trying to get it so when i go to populate the data it erases whats in there and puts new info in.

Link to comment
Share on other sites

all i want it to do is. That when i click populate it deletes all the information that is in the table and fills in what i have in code.

Like i have a table with

name type cost

arsenal soccer $50

 

but in my code ive changed to info to become

arsenal soccer-club $50.

 

Cause if i repopulate the data it just duplicates and i dont really want that

 

Thanks in advance

Link to comment
Share on other sites

all i want it to do is. That when i click populate it deletes all the information that is in the table and fills in what i have in code.

Like i have a table with

name type cost

arsenal soccer $50

 

but in my code ive changed to info to become

arsenal soccer-club $50.

 

Cause if i repopulate the data it just duplicates and i dont really want that

 

Thanks in advance

That's the update indicated earlier.

Link to comment
Share on other sites

i tried to just delete it, but ended up getting t-string error

$sql = DELETE * FROM tbl_product; //drop all data , then insert

$sql =  "INSERT INTO tbl_product VALUES " .
"(0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', ''), " .
"(0, 16, 'Abu Garcia Cardinal CSW173 Fishing Reel', 'A fis4hing rod !!!!!!!!!', '62.95', '1000', '','', '', '')";

Link to comment
Share on other sites

i guess your insert is invalid you can only insert one value per statement

 

$sql =  "INSERT INTO tbl_product VALUES " .

"(0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', ''), " ;

 

Link to comment
Share on other sites

<?php		/* Populate The products Table 
	** Use an Include file to open the database
	*/

    include( "connect.inc" );


$sql =  "INSERT INTO tbl_product VALUES (0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', '')";
// adding this is invalid"(0, 16, 'Abu Garcia Cardinal CSW173 Fishing Reel', 'A fis4hing rod !!!!!!!!!', '62.95', '1000', '','', '', '')";
//put this on another insert statement
//replace your delete with this
//$sql ="DELETE * FROM tbl_product"; <--- you should put here a condition or it wioll delt all records



if(mysql_query($sql)){
  echo("<p>Product table successfully populated!</p>");	
}
else{
  print("<p>Error adding to Product table: " . mysql_error() . "</p>");	
}
?>

Link to comment
Share on other sites

haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ;D

i tried to just delete it, but ended up getting t-string error

$sql = "DELETE * FROM tbl_product"; //drop all data , then insert

$sql =  "INSERT INTO tbl_product VALUES " .
"(0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', ''), " .
"(0, 16, 'Abu Garcia Cardinal CSW173 Fishing Reel', 'A fis4hing rod !!!!!!!!!', '62.95', '1000', '','', '', '')";

 

then that is almost right you only missed " on your delete

try that now

 

 

Link to comment
Share on other sites

nah try

 

$sql = "DELETE * FROM tbl_product"; //drop all data , then insert

mysql_query($sql );

 

$sql =  "INSERT INTO tbl_product VALUES " .

"(0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', ''), " .

"(0, 16, 'Abu Garcia Cardinal CSW173 Fishing Reel', 'A fis4hing rod !!!!!!!!!', '62.95', '1000', '','', '', '')";

mysql_query($sql);

 

maybe you ddont use mysql_query or if you did you put them together that over right the above query try that now

Link to comment
Share on other sites

<?php		/* Populate The Staff Table 
	** Use an Include file to open the database
	*/

    include( "connect.inc" );

*/$sql = "DELETE * FROM tbl_product"; //drop all data , then insert
mysql_query($sql );

   $sql =  "INSERT INTO tbl_product VALUES " .
   "(0, 11, 'Abu Garcia Cardinal CSW172 Fishing Reel', 'A fishing rod !!!!!!!!!', '63.95', '1000', '36d29b9445468ee556caa70d0e7f43b7','36d29b9445468ee556caa70d0e7f43b7', '', ''), " .
   "(0, 16, 'Abu Garcia Cardinal CSW173 Fishing Reel', 'A fis4hing rod !!!!!!!!!', '62.95', '1000', '','', '', '')";
mysql_query($sql);


if(mysql_query($sql)){
  echo("<p>Product table successfully populated!</p>");	
}
else{
  print("<p>Error adding to Product table: " . mysql_error() . "</p>");	
}
?>

 

still same problem even if i do that. Its just adding on the to table its not deleting anything

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.