Jump to content

help code


fer0an

Recommended Posts

hello

I'm using some code for add data into one table.

I need add on tid number from 1 to 26200 also I need for each 5 number on cid one number for example

tid---------------cid

1-----------------1

2-----------------1

3-----------------1

4-----------------1

5-----------------1

6-----------------2

7-----------------2

8-----------------2

9-----------------2

10---------------2

11---------------3

12---------------3

13---------------3

14---------------3

15---------------3

.

.

.

.

below is my code , can anyone help me?

<?php

$dbuser = "***";
$dbpass = "***";
$dbhost = "localhost";
$dbname = "***";

// Connecting, selecting database
$con = mysql_connect($dbhost, $dbuser, $dbpass)
   or die('Could not connect: ' . mysql_error());
mysql_select_db($dbname) or die('Could not select database');
$tid=1;
while( $tid<=26200){

$query="INSERT INTO `jos_tag_term_content` (
`tid` ,
`cid`
)
VALUES ( '".$tid."', '$cid' ) ";
$tid++;
if (!mysql_query($query,$con))
  {
  die('Error: text add' . mysql_error());

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/218586-help-code/
Share on other sites

<?php

$dbuser = "***";
$dbpass = "***";
$dbhost = "localhost";
$dbname = "***";

// Connecting, selecting database
$con = mysql_connect($dbhost, $dbuser, $dbpass)
   or die('Could not connect: ' . mysql_error());
mysql_select_db($dbname) or die('Could not select database');
$tid = 1;
$cid = 1;
while( $tid<=26200){

$query="INSERT INTO `jos_tag_term_content` (
`tid` ,
`cid`
)
VALUES ( '".$tid."', '$cid' ) ";
$tid++;
if ($tid % 5 == 0)
{
   $cid++;
}
if (!mysql_query($query,$con))
  {
  die('Error: text add' . mysql_error());

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/218586-help-code/#findComment-1133842
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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