sorting the contents on a record field ... - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-10-2011, 01:20 PM   #1 (permalink)
Regular User
 
Join Date: Nov 2008
Posts: 20
Default sorting the contents on a record field ...

Hello:

When I call up a specific record, I need to sort the contents of "tblpartmanuf" and replace that field with the sorted information. Lets say the record is:

tblpartnumber tblpartmanuf
12544 GFSD

After I edit some other fields, automatically sort the tblpartmanuf field so that it is:
12544 DFGS




$sql="SELECT tblpartnumber, tblpartmanuf FROM tblparts WHERE tblpartnumber ='$frmpartfinder'";
$result = mysql_query($sql) or die('Error: ' . mysql_error());
pepe_lepew1962 is offline   Reply With Quote
Sponsored Links
Old 11-10-2011, 10:16 PM   #2 (permalink)
Junior Member
 
Join Date: Nov 2011
Posts: 6
Default Re: sorting the contents on a record field ...

i like to read informative blogs and this blog is also so good and helpful.
yourluxurygucci is offline   Reply With Quote
Old 11-25-2011, 10:58 AM   #3 (permalink)
Regular User
 
Join Date: Sep 2010
Posts: 30
Default Re: sorting the contents on a record field ...

doing it in single shot is very difficult (at least to me).
You better grab that into PHP variable and then break the string into single letters, sort them, join them and send them back to DB.
PradeepKr is offline   Reply With Quote
Old 11-25-2011, 11:14 AM   #4 (permalink)
Regular User
 
Join Date: Sep 2010
Posts: 30
Default Re: sorting the contents on a record field ...

Try this,
PHP Code:
<?php 

$sql
="SELECT tblpartnumber, tblpartmanuf FROM tblparts WHERE tblpartnumber ='$frmpartfinder'";
$result mysql_query($sql) or die('Error: ' mysql_error());
while(
$row mysql_fetch_array($result))
{
  
//$letters = explode ('', $row['tblpartmanuf']);
  
$letters str_split(row['tblpartmanuf']);
  
sort($letters);
  
$letters implode(''$letters) ;

  
$sql="UPDATE TABLE tblparts SET tblpartmanuf = '$letters' WHERE tblpartnumber ='$frmpartfinder'";
  
$result mysql_query($sql) or die('Error: ' mysql_error());
  
  if(
mysql_affected_rows()>0)
  {
    echo 
'Updated successfully.';
  } 
  else
  {
    echo 
'Failed to update';
  }
}

?>
PradeepKr is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:18 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting