Jump to content

harchew

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

harchew's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Its working perfectly. Thank you so much (Bow...)
  2. How do I validate an user name in such a way that, it must contain at least an alpha and number. Only alpha,number and ._ are allow for the user name otherwise return invalid.
  3. I need to perform a sql statement to retrieve all data staring with non-alphabet's eg(8tel, 5go, 1Sir...). I tired using the method but its not working.. Select * from table where column LIKE '[0-9]%' May i know what went wrong?
  4. <?php header("Content-type: application/vnd-ms-excel"); header("Content-Disposition: attachment; filename=sales_report.xls"); ?> <?php $result = mysql_query("Select * from Subscriptions order by issue_code,attn"); ?> <table> <tr align="left"> <th>Attn</th> <th>Language</th> <th>Company</th> <th>Address L1</th> <th>Address L2</th> <th>Country</th> <th>Postal</th> <th>Issue Start</th> <th>Issue End</th> <th>PnL Code</th> </tr> <?php while ($row = mysql_fetch_array($result)): ?> <tr> <td><?php echo $row['attn']; ?></td> <td><?php echo $language; ?></td> <td><?php $result2 = mysql_query("Select * from subscribers where id = $row[subscriber_id]"); $row2 = mysql_fetch_array($result2); echo $row2['company']; ?></td> <td><?php echo $row['address1']; ?></td> <td><?php echo $row['address2']; ?></td> <td><?php echo $row['country']; ?></td> <td><?php echo $row['postal']; ?></td> <td><?php echo $row['issue_start']; ?></td> <td><?php echo $issue_end; ?></td> <td nowrap><?php echo $row['mag_code'] . ' / ' . $row['issue_code'] . ' / ' . $row['id'];?></td> </tr> <?php } endwhile; ?> </table>
  5. I'm using the code below to export all data to an excel. header("Content-type: application/vnd-ms-excel"); header("Content-Disposition: attachment; filename=sales_report.xls"); However some of data beings with zero and excel will auto remove it from the column. So is that anyway I can configure the header to define the column type as text. or any solution out there can actually prevent excel form removing zeros. FYI by default the column is set as general.
  6. wow thank u so much. solve my problem effortlessly... this is the edited code i used <![CDATA[ content ]]>
  7. Currently working on php and xml This is my xml format : <?xml version="1.0"?> <data> <event> <content> The pre element defines preformatted text. The text enclosed in the pre element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.The pre element defines preformatted text. The text enclosed in the pre element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.<BR><strong>Text to be bold</strong></BR> </content> </event> </data> I am using the following code to display the data : <?php $file = @file_get_contents("myxml file name"); if($file) { $xmlFileData = file_get_contents("myxml file name"); $xmlData = new SimpleXMLElement($xmlFileData); foreach($xmlData->event as $event) { echo $event->content; } } ?> Its able to display some portion of the content. however the script will stop displaying the rest of the content after the <BR> symbol. So is there any wrong with my php coding? I need to display all the content without removing the text format. is there any solution out there... thank you in advance...
  8. Basically I have successfully found a function that can send email with attachment. However wasn't able to send multiple attachments. I tried sending two attachments manually, but only the second was successfully attached. Can someone look through the code below and point out my mistake. Thank you in advance.... <?php if(isset($_POST['send'])) { $fileatt_one = $_FILES['attachment']['tmp_name'][0]; $fileatt_type_one = "application/octet-stream"; // File Type $fileatt_name_one = $_FILES['attachment']['name'][0]; // Filename that will be used for the file as the attachment $fileatt_two = $_FILES['attachment']['tmp_name'][1]; $fileatt_type_two = "application/octet-stream"; // File Type $fileatt_name_two = $_FILES['attachment']['name'][1]; // Filename that will be used for the file as the attachment $email_from = "a@gmail.com"; // Who the email is from $email_subject = "Test"; // The Subject of the email $email_txt = "Testing 123"; // Message that the email has in it $email_to = "a@gmail.com"; // Who the email is too $headers = "From: ".$email_from; $file_one = fopen($fileatt_one,'rb'); $data_one = fread($file_one,filesize($fileatt_one)); fclose($file_one); $file_two = fopen($fileatt_two,'rb'); $data_two = fread($file_two,filesize($fileatt_two)); fclose($file_two); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $data_one = chunk_split(base64_encode($data_one)); $data_two = chunk_split(base64_encode($data_two)); $headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" ."--{$mime_boundary}\n" ."Content-Type:text/html; charset=\"iso-8859-1\"\n" ."Content-Transfer-Encoding: 7bit\n\n" .$email_txt . "\n\n"; $email_message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type_one};\n" ." name=\"{$fileatt_name_one}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data_one . "\n\n" ."--{$mime_boundary}--\n"; $email_message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type_two};\n" ." name=\"{$fileatt_name_two}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data_two . "\n\n" ."--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } } ?> <form enctype="multipart/form-data" name="send" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="file" name="attachment[]" size="50" /> <input type="file" name="attachment[]" size="50" /> <input type="submit" name="send" value="Submit"> </form>
  9. Wow it's works. Really thanks for the solution. Learned something new today...
  10. Thanks for the quick reply. I understand what you mean, I tried various way including declare it as a variable instead of string but still can't work. Perhaps you can show me an example. Thank U....
  11. I created a function name createTextField() to display all my textfield. function createTextField($name,$value) { return "<input type=\"text\" name=\"$name\" value=\"$value\" class=\"txtField\">"; } I declared the function with a variable : $input_addcat = createTextField('addcat',NULL); and display it using echo $input_addcat. its works perfectly for this case. However when I tired using the same function for drop list : function createList() { return "<select name=\"a\"> for ($a=0; $a < 10; $a++){ <option value=\"a\">1</option> } </select>"; } decalre it by $list = createList(); and display it using echo $list; The drop list only show a single value. For some reason the for loop didn't work in the function. Any solution to it? I have been working all night long just to figure out a solution for it. Really appreciate your help. Thank you in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.