PDA

View Full Version : Changing all rows in a table from a selected field.


Davey
08-20-2004, 04:12 PM
Couldn't think how to title this one.
In my table, I have a field called 'cid'.
There are 518 rows at the moment, I need to change the URL because it takes up a lot of space. I want the url to be changed to a special part of the URL, the "character id" string.
The URL looks like this:

(dont forget to add https://www it shows up funny on forum so I removed it.)
.novaworld.com/NWCommunities/charStats.aspx?id=xxxxxxxxxxx&productid=xxxxxx&playerCard=1

The first string 'id' is the string I need all the 'cid' fields changed to. This is the character id string. The second 'productid' string, is the ID of a certain game (3 different IDs atm). Space isn't the only reason I want this changed. I currently have it so that it only shows stats from the certain game, even if the player plays more than that 1 game. So with the character ID, I could just build a URL for their stats to each game, if you see what I mean.
See attachment for the piece of the URL I need.

Is it possible to update all 518 fields from:
(dont forget to add https://www it shows up funny on forum so I removed it.)
.novaworld.com/NWCommunities/charStats.aspx?id=xxxxxxxxxxx&productid=496057&playerCard=1 to xxxxxxxxxxx only?
Even if this is done via script, or perhaps even a phpMyAdmin query.

I believe it'd need a regexp of some kind to get 'xxxxxxxxxxx' from the string? Maybe not? This is the only bit I need help with, getting 'xxxxxxxxxxx' from that url string.

Thx for help.

Brad
08-21-2004, 03:20 AM
I don't understand what you are looking to do, can you provide us with some sample info and show us how you want it changed?

Davey
08-21-2004, 03:37 AM
Difficult to explain lol.
I need a specific part of a URL.
Then I need to make a script which replaces each URL with the string of the URL I need.

The url is:
// ignore the space
https://www .novaworld.com/NWCommunities/charStats.aspx?id=xxxxxxxxxxx&productid=496057&playerCard=1
I need to get the xxxxxxxxxxx bit out of that URL string. Possible?

Brad
08-22-2004, 04:35 AM
Difficult to explain lol.
I need a specific part of a URL.
Then I need to make a script which replaces each URL with the string of the URL I need.

The url is:
// ignore the space
https://www .novaworld.com/NWCommunities/charStats.aspx?id=xxxxxxxxxxx&productid=496057&playerCard=1
I need to get the xxxxxxxxxxx bit out of that URL string. Possible?
It is possible, but I am not skilled in asp.net. In php however, you would get the var as so:

$_GET['id']

Davey
08-22-2004, 11:07 AM
I figured it out, but I ballsed my database up.
It changed all the CID to the 1st CID only. I can't figure out why it did that.

<?php
error_reporting(E_ALL & ~E_NOTICE);
// details removed for security reasons.
$dbase = mysql_connect('*','*','*');
mysql_select_db('*');
//
$cheatdb1 = mysql_query("SELECT * FROM cheatdb",$dbase);
echo "begin database...<br><br>";
$count = 0;
while ($cheatdb = mysql_fetch_array($cheatdb1))
{
$count++;
$url = parse_url($cheatdb['cid']);
parse_str($url['query'], $outcome);
mysql_query("UPDATE cheatdb SET cid='" . $outcome['id'] . "'",$dbase);
}
echo "<br>end database.";
?>