Explode() in sql?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Explode() in sql?

Post by PHP_ColdFusion »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The Following code will not show the rows of information on my page after the header.  is it not pulling it out of the database?  i know its putting it in the database at least.  in the data base on that table i have 3,2 which is the corrisponding information that is supposed to go in the database on the implode.  but why wont it explode that same data?  Please someone help me i've been beating this script up all day.

Thnx,

PhP_ColdFusion

Code: Select all

// if edit => Print
 	case 'Print':
		if (isset($_POST['select'])) { 
		$Printed = implode(",", $select); 
		}

		$Printed2 = explode(",",$myrow["Print"]);

     		$sel = "UPDATE print
                    SET Print = '" . $Printed . "'         		    
       		    WHERE Num = '1'";

     		$sel2 = "select *
       		    FROM products
       		    WHERE ProductID = '" .  . "'";
       		
		$result = mysql_query($sel,$con);
		
		if (!mysql_query($sel,$con))
 		 {
 		  echo '<tr>';
		  echo '<td><CENTER>';
		  echo 'Error: ' . mysql_error();
		  echo '<br><a href="javascript:history.go(-1);">Go Back</a>';
		  echo '</td>';
		  echo '</tr>';
		  die();
 		 } elseif (mysql_query($sel,$con)) {
		  echo '<frame width=600>';
 		  include 'templates/paperhead.php';
			while($row = mysql_fetch_array($result))
  			{
			 echo '<tr>';
			 echo '<td style="border:none;">'.$row['ProductID'].'</td>';
			 echo '<td style="border:none;">'.$row['category'].'</td>';
			 echo '<td style="border:none;">'.$row['Supplier'].'</td>';
			 echo '<td style="border:none;">'.$row['Serial'].'</td>';
			 echo '<td style="border:none;">'.$row['Product'].'</td>';
			 echo '<td style="border:none;">'.$row['Description'].'</td>';
			 echo '<td style="border:none;">'.$row['LeadTime'].'</td>';
			 echo '<td style="border:none;">$ '.$row['UnitPrice'].'</td>';
			 echo '<td align=right style="border:none;"> '.$row['UnitsOnHand'].'</td>';
			 echo '</tr>';
			}

		  echo '</frame>';
		  die();
 		 }
            break;
 }
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Where is $myrow set and what is it set to?
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

corrections

Post by PHP_ColdFusion »

after loking back over that i noticed that i didn't have some stuff right (eg. myrow and other things.)

this one is what i needed to send lol.

Code: Select all

// if edit => Print
 	case 'Print':
		if (isset($_POST['select'])) { 
		$Printed = implode(",", $select); 
		}

     		$sel = "UPDATE print
                    SET Print = '" . $Printed . "'         		    
       		    WHERE Num = '1'";

     		$sel2 = "SELECT Print FROM print
       		    WHERE Num = '1'";
       		
       		$result = mysql_query($sel2,$con);
       		    
       	        $Printed2 = explode(",", mysql_fetch_array($result));
       		
       		$sel3 = "SELECT *
                    FROM products
                    WHERE ProductID = '" . $Printed2 . "'";
       		
		$result2 = mysql_query($sel3,$con);
		
		if (!mysql_query($sel,$con))
 		 {
 		  echo '<tr>';
		  echo '<td><CENTER>';
		  echo 'Error: ' . mysql_error();
		  echo '<br><a href="javascript:history.go(-1);">Go Back</a>';
		  echo '</td>';
		  echo '</tr>';
		  die();
 		 } elseif (mysql_query($sel2,$con)) {
		  echo '<frame width=600>';
		  echo $Printed2;
 		  include 'templates/paperhead.php';
                    while($row = mysql_fetch_array($result2)) {
                     echo '<tr>';
		     echo '<td style="border:none;">'.$row['ProductID'].'</td>';
		     echo '<td style="border:none;">'.$row['category'].'</td>';
		     echo '<td style="border:none;">'.$row['Supplier'].'</td>';
		     echo '<td style="border:none;">'.$row['Serial'].'</td>';
		     echo '<td style="border:none;">'.$row['Product'].'</td>';
		     echo '<td style="border:none;">'.$row['Description'].'</td>';
		     echo '<td style="border:none;">'.$row['LeadTime'].'</td>';
		     echo '<td style="border:none;">$ '.$row['UnitPrice'].'</td>';
		     echo '<td align=right style="border:none;"> '.$row['UnitsOnHand'].'</td>';
		     echo '</tr>';
                     }
		  echo '</frame>';
		  die();
 		 }
            break;
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you might want to edit your post to include

Code: Select all

tags, feyd was kind enough to do it for you the first time.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_fetch_array() returns an array. Explode() does not operate on arrays.
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

oh hum... is there any way to do what i am looking to do then?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Take a look at what mysql_fetch_array() is returning. ;)
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

ok yeah you lost me there
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

nice icon btw
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

n/m i get it now
i wasn't sure exactly how the explode function worked.

thanks guys
Post Reply