kpasiva
-
Posts
13 -
Joined
-
Last visited
Never
Posts posted by kpasiva
-
-
Welcome
Always here to help,
-Siva
-
Hi,
You have to use string handling functions to achieve this,
<?php if (strpos($the_product_info['products_model'],'g') !== false) { echo 'It works!!!'; } ?>
-
Hi,
There is no error in the given script, since i have executed the script locally with test table. You might made some error while integrating with your original file.
Please check you might for got to remove unwanted curly braces ({)
-Siva
-
Alright,
Here is the script for you
<?php $host = 'localhost'; $user = 'username'; $pass = 'password'; $db = 'database_name'; $table = 'zen_address_book'; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $replace = array( 'entry_firstname' => 'First Name', 'entry_lastname' => 'Last Name', 'entry_street_address' => 'Address', 'entry_suburb' => 'City', 'entry_state' => 'County', 'entry_postcode' => 'Post Code' ); $values = mysql_query("SELECT entry_firstname, entry_lastname, entry_street_address FROM ".$table.""); $i=0; while ($rowr = mysql_fetch_assoc($values)) { if($i==0) { foreach(array_keys($rowr) as $title) $csv_output .= '"'.str_replace(array_keys($replace), $replace, $title).'",'; $csv_output .= "\n"; } foreach ($rowr as $key => $value) { $csv_output .= '"'.$value.'",'; } $csv_output .= "\n"; $i++; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?>
-
Oh.. Got it but any way you have to use separator to place the title in a separate columns.
Instead of using SHOW COLUMNS to get column title, Use array_keys from the result row
$title_array = array_keys($row);
then it will return only the selected column titles from the select row. But you have to use mysql_fetch_assoc instead of mysql_fetch_row
-
Hi,
You forgot to add column separator (,) while inserting column titles,
replace the line
<?php $csv_output .= str_replace(array_keys($replace), $replace, $row['Field'])." "; ?>
to
<?php $csv_output .= '"'.str_replace(array_keys($replace), $replace, $row['Field']).'",'; ?>
-
The script used to set header and display image content,
<?php //setting the header information to display the image header('Content-type: $ftype'); echo $fdata; ?>
has to be moved to the else part because the error msg ("No image available") can't be displayed if session doesn't exist.
Check the script by moving the above script to the else part whether it shows the error - "No image available".
-
Hi,
Need to add script to check user selections and the query has to be formed as,
<?php $query = "SELECT book_id, book_title,author,keyword FROM book"; if($_POST['field']=='aname') $query .= " WHERE author LIKE '%$search%'"; elseif($_POST['field']=='title') $query .= " WHERE book_title LIKE '%$search%'" elseif($_POST['field']=='keyword') $query .= " WHERE keyword LIKE '%$search%'" ?>
-
Hi,
Set your domain name in the place of yourdomain.com
setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
-
Hello,
The email content is sending in Text format instead of HTML. You can use,
<a href="http://www.example.com/index.php?main_page=terms">Click here</a>
In Text format. Put the full url without anchor tag,
Click here http://www.example.com/index.php?main_page=terms
Otherwise change your email format to HTML.
-
Use,
$message = file_get_contents('reg_confirm.tpl');
-
Hi,
Use, iif(in_array($mod_array[0],(array)$items).
The warning will come if the second argument is not an array. So put (array) in front of the array variable ($items). The same should be added for all array functions otherwise it will show up warning if the argument is not an array.
[SOLVED] Whats the code for 'contains'
in PHP Coding Help
Posted
Welcome
Always here to help
-Siva