Latest Posts in PHP

in PHP
 
0
 
<?PHP

include('config.php');


  function cleanData(&$str)
  {
    $str = preg_replace("/\t/", "\\t", $str);
    $str = preg_replace("/\r?\n/", "\\n", $str);
    if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
  }

  // filename for download
  $filename = "Piante_" . date('Ymd') . ".xls";

  header("Content-Disposition: attachment; filename=\"$filename\"");
  header("Content-Type: application/vnd.ms-excel");

  $flag = false;
  $result = mysql_query("SELECT * FROM photo where flag='active'") or die('Query failed!');
  while(false !== ($row =mysql_fetch_assoc($result))) {
    if(!$flag) {
      // display field/column names as first row

      echo implode("\t", array_keys($row)) . "\r\n";
      $flag = true;
    }
    array_walk($row, 'cleanData');
    echo implode("\t", array_values($row)) . "\r\n";
  }
  exit;
?>

Hy i'm using this code to export excell from the db, i'm having problem that when i open the file excell show me an error something like different format that specified by the file name open anyway?, its work anyway, next problem is that i whant to customize he collum name, i see that array_keys, but i'm not able to change it i've tryied to make only echo with \r\n with the name of columns but nothing...

Re: in PHP
 
0
 

The answer is provided by broj1 in the second post of this thread. You can save the value in a input type hidden element within the form. Once the form is posted you can pick up the value in your php script like you would for any other input element.

in PHP
 
0
 

I want to create a form builder in php. But i dont know how to do this, So please help me.
Thank you all

in PHP
 
0
 
<?php
ob_start();
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include "admin/include/config.php";
include "temp_config.php";
//session_start();
    $tmp = $_SESSION['tmp_id'];
    $cartsql = mysql_query("SELECT * FROM `cart` WHERE `temp_id` = '$tmp'");
    $cartnum = mysql_num_rows($cartsql);
// For Check the cart is empty or not...
ob_end_flush();
?>
<!DOCtype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Provisional Cart</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
     <link href="style.css" rel="stylesheet">
     <link href="css/responsive.css" rel="stylesheet">


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans">

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<meta name="google-translate-customization" content="eea09d3bd0adcb0b-9cf911aa5a3a0bc8-ge2e6350b9a611e3c-1d"></meta>

  </head>
    <body>
        <div class="container header">
            <div class="row">
                <div>                    
                    <div class="logo">
                        <a href="index.php"><img src="images/ps-logo.png" class="logo"/></a>                   
                    </div>                    
                </div>
            </div>
        </div>

        <div class="container body">
            <div class="row">
                <div>
Re: in PHP
 
0
 

how to support google translate in php form on my message system?

Re: in PHP
 
1
 

see your code

<!--Table data-->
            <?php
                $q_cnt = $conn->query("DESCRIBE `employee` ");
                while($row_cnt = $q_cnt->fetch()){
                $d_cnt = $row_cnt['Field'];
                    echo " <tr>";
                $sql_data = "SELECT * From `employee` ";
                $query_data = $conn->query($sql_data);
                while ($row_data = $query_data->fetch()){
                    ?>
                            <td>
                                <?= $row_data[ $d_cnt ] ?>
                            </td>
                    <?php
                    }
                    echo "</tr>";
                    }
                    ?>
        </table>

The first while loop create the <tr> which create a row, and for each row, the second while loop populate the row with 2 <td>. What your can do is

<table class="table">
        <tr>
            <?php
                $sql = "DESCRIBE `employee`";
                $query = $conn->query($sql);
                $columns = array();
                while ($row = $query->fetch()) {   
                array_push($columns,$row['Field']);
            ?>
                <th><?=  $row['Field']; ?></th>
            <?php } ?>
        </tr>
        <?php 
            $sql_datas = "SELECT * From `employee` ";
            $query = $conn->query($sql_datas);
            while ($row_data = $query->fetch()) {
        ?>
        <tr> 
            <?php 
            foreach($columns as $column){ 
                echo "<td>$row_data[$column]</td>"; 
            } 
            ?> 
            </tr>     
        <?php } ?>
    </table>
Re: in PHP
 
0
 

that code can populate the table's apparently it has a downside to it instead of by row it adds by columns please see the picture

here's the code

 <table class="table">
                <!--Table header-->
                <tr>
                    <?php
                    $sql = "DESCRIBE `employee`";
                    $query = $conn->query($sql);
                    while ($row = $query->fetch()) {
                        $d = $row['Field'];
                        ?>
                        <td><?= $d; ?></td>
                    <?php } ?>
                </tr>





    <!--Table data-->
            <?php

                $q_cnt = $conn->query("DESCRIBE `employee` ");
                while($row_cnt = $q_cnt->fetch()){
                $d_cnt = $row_cnt['Field'];

                    echo " <tr>";
                $sql_data = "SELECT * From `employee` ";
                $query_data = $conn->query($sql_data);
                while ($row_data = $query_data->fetch()){
                    ?>
                            <td>
                                <?= $row_data[ $d_cnt ] ?>
                            </td>
                    <?php
                    }
                    echo "</tr>";
                    }
                    ?>

        </table>
Attachments 1.jpg 58.27 KB
Re: in PHP
 
0
 

sqlite might be an option for you

Re: in PHP
 
0
 

Wonder if I missing your meaning again now. Maybe what you wish for is:

<tr>
    <?php
    foreach($row['Field']){
        echo "<td>$row_data[$row['Field']]</td>";
    }
    ?>
</tr>

which this code populate the table of <td> with data from tables without manually to set the <td> manually

Re: in PHP
 
0
 

Typically MySQL goes hand in hand with php but you can use any you like.

Re: in PHP
 
0
 

Sorry @lps you must have mis-understood the question. the problem I'm having is populating the data under the table header. I'm not yet done on populating the tables.

although your ahead of me coding the update buttons and delete

At the moment im using pure php for analysis of the flow I will migrate that on ajax codes once this problem is solve

Thanks

in PHP
 
0
 

I need to create a new site in PHP and need to host in cloud. Can anyone say in which DB I can host my site?

Re: in PHP
 
0
 

This error normally means that the connection is being blocked either on your server's side (outbound) or on the receiving server's side (inbound).

Re: in PHP
 
0
 

OK, I have Mailchimp working perfectly. Exactly the way I like things.

1st, there is the basic form that you can provide to visitors to register for more information or for a newsletter, or whatever.

I set up my mail list with the normal information - first / last / email
then I added a category / memberID / username as well

The category field I use to determine what type of subscriber it is..
if they subscribe for more info or newsletter, I record them as a 'Visitor' and they don't have any memberID or username.

When someone joins/registers as a member using my normal registration form on the site, I make sure that all of the variables have values assigned that would be required in the mail list, including memberID and Username used to register.

When someone registers they must Verify their email address to gain access to their back office, and that just seemed like the logical place to update their information on the mail list, since I know at that point that their email entered is verifiable.

So I simply do an include of a short little script that calls the related function in the MCAPI Class. I would include the class in here but it is 3000 lines long, so probably not a good idea.

// use this include in the verify script
include "mclinks/mcapi_listSubscribe.php" ; // New Subscription 

// to call this listSubscribe script

/**
Subscribe a New Member to a List using the MCAPI.php
class and do some basic error checking.
**/
require_once 'mclinks/MCAPI.class.php';
require_once 'mclinks/config.inc.php'; //contains apikey

$api = new MCAPI($apikey);

$merge_vars = array('EMAIL'=>$mem_cur_email, 'FNAME'=>$mem_fname, 'LNAME'=>$mem_lname,
                     'CATEGORY'=>$mem_category, 'USER'=>$mem_user, 'MEM_ID'=>$mem_id
                    );

// disabled sending a confirmation email - by setting double_optin=false
$retval = $api->listSubscribe( $listId, $my_email, $merge_vars, $email_type='html', $double_optin=false, $update_existing=true );

if ($api->errorCode){
  $Code = $api->errorCode;
  $Msg = $api->errorMessage;

  tech_alert('<br>Unable to load listSubscribe()!<br>Code='.$Code.'<br>Msg='.$Msg.'<br>my mail value:'.$my_email);

} else {

  $Code = '';
  $Msg = '';

  tech_alert('<br>Subscribed - <br>Returned: '.$retval);

}

the config file that is required is what contains all the private information relevant to my account and list.

the tech_alert is just a little function I use to email myself when something happens that shouldn't, or to tell me something works during testing.

As it turns out, my script that allows members to update their personal information, which sometimes includes their email address, also forces them to verify if they changed it, so I wrote some conditional code to determine if it was an add or an update, and a seperate little script to call the listUpdate function from the class.

But in talking with the support staff at MailChimp (very knowledgable and helpful, once you get to them), they suggested that I forego the update script.

They suggested just using the listSubscribe for both of them because the way it works is if you are subscribing with an existing email address, and have the flag set to update if exists, it works the same way as the update and just updates the fields that are different.

So now, if someone registers that had subscribed as a visitor, the subscribe script automatically changes their category from visitor to member and adds their memberID and username to the mail list record for future use

and if they hadn't subscribed as a visitor, it simply adds a new record.

And when a member makes their first purchase, I call the same script which basically just changes their category from 'member' to 'customer'

Now, I can send emails to each category individually or any combination of the 3, depending on what the email is intended for.

it was as simple as adding 1 folder in my public html that contains the config, the class, and the listSubscribe and calling it when I need it.

Hope this wasn't too verbose, and that it will be helpful to someone. If anyone wants specific questions answered, I would be more than happy to help.

Ya'll have a great day.
Douglas

Re: in PHP
 
0
 

googled and found thisClick Here

PHP Tag Cloud