Page 1 of 1

Explode() in sql?

Posted: Thu Jan 04, 2007 2:22 pm
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]

Posted: Thu Jan 04, 2007 2:56 pm
by feyd
Where is $myrow set and what is it set to?

corrections

Posted: Thu Jan 04, 2007 3:14 pm
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;

Posted: Thu Jan 04, 2007 3:18 pm
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.

Posted: Thu Jan 04, 2007 3:27 pm
by feyd
mysql_fetch_array() returns an array. Explode() does not operate on arrays.

Posted: Thu Jan 04, 2007 3:28 pm
by PHP_ColdFusion
oh hum... is there any way to do what i am looking to do then?

Posted: Thu Jan 04, 2007 3:35 pm
by feyd
Take a look at what mysql_fetch_array() is returning. ;)

Posted: Thu Jan 04, 2007 3:49 pm
by PHP_ColdFusion
ok yeah you lost me there

Posted: Thu Jan 04, 2007 3:54 pm
by PHP_ColdFusion
nice icon btw

Posted: Thu Jan 04, 2007 4:28 pm
by PHP_ColdFusion
n/m i get it now
i wasn't sure exactly how the explode function worked.

thanks guys