Current location: Hot Scripts Forums » Programming Languages » PHP » Help - Storing retrieved MySQLdata


Help - Storing retrieved MySQLdata

Reply
  #1 (permalink)  
Old 03-13-10, 01:27 PM
Raffikki529 Raffikki529 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Help - Storing retrieved MySQLdata

Hi everyone!

I've just started learning php a while back and I am having a problem figuring this out. I've spent days searching for a solution but I think I don't know the correct terms etc...

I have a form that submits to a php page with the amounts of products, the generated data retrieved from the mysql database (id, supplier, product_name) displays perfectly inside a table. If I try to assign the information retrieved from the database to a variable, the variable is returned blank or as 1.

So how can store this information(table with retrieved data) and send it via email?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-13-10, 05:10 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Please post your code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-14-10, 05:45 AM
Raffikki529 Raffikki529 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
PHP Code:

<html>
<body bgcolor="#333333" style="color:white; font-family:Verdana, Geneva, sans-serif;" >
                                                                    
                                                                        <table border="1" bordercolor="#000000" bgcolor="#00FFFF" style="color:black" width="985px">
                                                                        
                                                                        <tr>
                                                                        <th width="300px">Product</th>
                                                                        <th width="300px">Part #</th>
                                                                        <th width="300px">Supplier</th>
                                                                        <th>Amount</th>
                                                                        </tr>
                                                                        
<?                                                                        


$host 
"localhost";
$user "root";
$pass "";
$database "products";

$linkID mysql_connect($host$user$pass) or die("Could not connect to host.");
mysql_select_db($database$linkID) or die("Could not find database.");

$query "SELECT * FROM products ORDER BY supplier, product";
$resultID mysql_query($query$linkID) or die("Data not found.");


while(
$row mysql_fetch_array($resultID))

          {
            
            
$fok $row['id'];
            
$amount $_POST[$fok] . "</td>";

if (
$amount != 0) {
                                                
                                            
            



                                                            echo 
"<tr><td>";
                                                            echo 
$row['Product'] . "</td><td>";

                                                            
                                                            echo 
$row['Part_Number'] . "</td><td>";
                                                            
                                                            echo 
$row['Supplier'] . "</td><td>";
                                                            
                                                            echo 
$amount;
                                                            
                                                            echo 
"</tr>";
                                                            
                                                            


            
                
                }
        }
        echo 
"</table>";
        
?>
        
</html>
This file is included in a submit.php file.
If the inc file is set as a variable and displayed again, it displays "1".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-14-10, 09:16 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Can you post the assignment statement you're using?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-14-10, 09:31 AM
Raffikki529 Raffikki529 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
PHP Code:

           $to "admin@email.com";

           
$headers "From: orders@email.com";
           
$subject "Order from " . - $_POST['Name'];
           
$name_field $_POST['Name'];
           
$surname_field $_POST['Surname'];
           
$tel_field $_POST['Tel'];
           
$info_field $_POST['Info'];
           
$address_field $_POST['Address'];
    
    



                                                                        
                            
        
        
                                                            
$inc = include( 'inc.php' );                        

                    
                                                    
                                                            
$body "From: $name_field\n $surname_field\n Email: $email_field\n Tel: $tel_field\n Information:\n $info_field Products:\n $inc;";
                                                            
$thanks "Thank you for using our online order system! We are processing your order and will get back to you soon!";
                                                            
                                                            

                                                            
                                            
                                                            
                                                            echo 
"<br>";
                                                            echo 
"<br>";
                                                            echo 
"Order has been submitted";
                                                            echo 
"<br>";
                                                            echo 
"<br>";
                     
                     
                        
                     
                    
                 
mail($to$subject$body$headers);
                 
mail($email_field$subject$thanks$headers);
             
                    echo 
$inc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-14-10, 09:44 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Change $subject = "Order from " . - $_POST['Name'];

to

$subject = "Order from - " .$_POST['Name'];
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
The Following User Says Thank You to wirehopper For This Useful Post:
Raffikki529 (03-15-10)
  #7 (permalink)  
Old 03-14-10, 10:06 AM
Raffikki529 Raffikki529 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
That explaines the subject in the email displaying incorrectly..thanks

but if the $inc variable at the bottom of the file still displays incorrectly. The $inc doesn't show the data retrieved from the mysql database. It only displays when the file is included, it only shows the data once, it is not stored in the variable, why? Should I use xml?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 03-14-10, 01:04 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Instead of $inc=include('inc.php'); you could use $inc=file_get_contents('inc.php');

Remember that because the file has .php as an extension, PHP is going to try to process it. If it's just text - you can use file_get_contents('inc.txt');
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 03-15-10, 12:29 PM
Raffikki529 Raffikki529 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
it works, but displays the code as text not as php code. I need it to display php or html code when called
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing dates in MySQL cnapsys Database 9 03-28-08 08:32 AM
[SOLVED] Storing multiple values in the same field Jay6390 Database 4 03-13-08 10:09 PM
Storing field names of a table when storing query results in a text file ??? Newbie2005 PHP 0 10-21-05 06:53 AM
Retrieved Forms Via Email depth09 HTML/XHTML/XML 2 01-07-05 02:30 PM
help plz: format retrieved Mysql data in HTML with PHP paulj000 PHP 2 10-19-03 09:03 PM


All times are GMT -5. The time now is 07:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.