wiggst3r
-
Posts
94 -
Joined
-
Last visited
Never
Posts posted by wiggst3r
-
-
Hi
I have the following code, which I want to replace with the correct code that will run a php script
if ! mount | grep -q /media/external; then echo "no backup" | mail you@home exit 1 fi
All it does is checks if my external usb hdd is mounted, if not, mails me.
I don't want to install any mail packages on my system. Just want to replace where the mail function is called, with a called to a php file
Thanks.
-
Hi
I have a table, with several rows. Each row is pulled from the db and then styled globally.
I have the following columns in the db:
catid, briefed, job, category, needed, timeofday, status, orderid, importancy
I can edit a rows details, via a script and what I'm looking to do is:
If a row has the importancy of '1' style that row with another colour.
I have this as my code so far:
<div id="listContainer"> <? foreach($list as $item) { // display eddited row and edit row form if(isset($_GET['state']) && $_GET['state'] == 'edit' && $_GET['catid'] == $item['catid']) { ?> <form action="save-digital.php" name="insert_priority" method="post"> <table> <tr> <td><input class="catid" name="catid" type="hidden" id="catid" value="<? echo $item['catid']; ?>"/></td> <td><input class="briefed" name="briefed" type="text" id="briefed" value="<? echo $item['briefed']; ?>"/></td> <td><input class="job" name="job" type="text" id="job" value="<? echo $item['job']; ?>"/></td> <td><input class="category" name="category" type="text" id="category" value="<? echo $item['category']; ?>"/></td> <td> <select name="needed" id="needed" class="needed"> <option value="<? echo $item['needed']; ?>" <?php if (isset($missing) && $_POST['needed'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['needed']; ?></option> <option value="Mon" <?php if (isset($missing) && $_POST['needed'] == 'Mon') { ?> selected="selected" <?php } ?> >Mon</option> <option value="Tues" <?php if (isset($missing) && $_POST['needed'] == 'Tues') { ?> selected="selected" <?php } ?> >Tues</option> <option value="Weds" <?php if (isset($missing) && $_POST['needed'] == 'Weds') { ?> selected="selected" <?php } ?> >Weds</option> <option value="Thurs" <?php if (isset($missing) && $_POST['needed'] == 'Thurs') { ?> selected="selected" <?php } ?> >Thurs</option> <option value="Fri" <?php if (isset($missing) && $_POST['needed'] == 'Fri') { ?> selected="selected" <?php } ?> >Fri</option> <option value="Ongoing" <?php if (isset($missing) && $_POST['needed'] == 'Ongoing') { ?> selected="selected" <?php } ?> >Ongoing</option> <option value="w/c" <?php if (isset($missing) && $_POST['needed'] == 'w/c') { ?> selected="selected" <?php } ?> >w/c</option></td> </select> <td> <select name="timeofday" id="timeofday" class="timeofday"> <option value="<? echo $item['timeofday']; ?>" <?php if (isset($missing) && $_POST['timeofday'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['timeofday']; ?></option> <option value="am" <?php if (isset($missing) && $_POST['timeofday'] == 'am') { ?> selected="selected" <?php } ?> >am</option> <option value="pm" <?php if (isset($missing) && $_POST['timeofday'] == 'pm') { ?> selected="selected" <?php } ?> >pm</option> <option value="1st" <?php if (isset($missing) && $_POST['timeofday'] == '1st') { ?> selected="selected" <?php } ?> >1st</option> <option value="2nd" <?php if (isset($missing) && $_POST['timeofday'] == '2nd') { ?> selected="selected" <?php } ?> >2nd</option> <option value="3rd" <?php if (isset($missing) && $_POST['timeofday'] == '3rd') { ?> selected="selected" <?php } ?> >3rd</option> <option value="4th" <?php if (isset($missing) && $_POST['timeofday'] == '4th') { ?> selected="selected" <?php } ?> >4th</option> <option value="5th" <?php if (isset($missing) && $_POST['timeofday'] == '5th') { ?> selected="selected" <?php } ?> >5th</option> <option value="6th" <?php if (isset($missing) && $_POST['timeofday'] == '6th') { ?> selected="selected" <?php } ?> >6th</option> <option value="7th" <?php if (isset($missing) && $_POST['timeofday'] == '7th') { ?> selected="selected" <?php } ?> >7th</option> <option value="8th" <?php if (isset($missing) && $_POST['timeofday'] == '8th') { ?> selected="selected" <?php } ?> >8th</option> <option value="9th" <?php if (isset($missing) && $_POST['timeofday'] == '9th') { ?> selected="selected" <?php } ?> >9th</option> <option value="10th" <?php if (isset($missing) && $_POST['timeofday'] == '10th') { ?> selected="selected" <?php } ?> >10th</option> <option value="11th" <?php if (isset($missing) && $_POST['timeofday'] == '11th') { ?> selected="selected" <?php } ?> >11th</option> <option value="12th" <?php if (isset($missing) && $_POST['timeofday'] == '12th') { ?> selected="selected" <?php } ?> >12th</option> <option value="13th" <?php if (isset($missing) && $_POST['timeofday'] == '13th') { ?> selected="selected" <?php } ?> >13th</option> <option value="14th" <?php if (isset($missing) && $_POST['timeofday'] == '14th') { ?> selected="selected" <?php } ?> >14th</option> <option value="15th" <?php if (isset($missing) && $_POST['timeofday'] == '15th') { ?> selected="selected" <?php } ?> >15th</option> <option value="16th" <?php if (isset($missing) && $_POST['timeofday'] == '16th') { ?> selected="selected" <?php } ?> >16th</option> <option value="17th" <?php if (isset($missing) && $_POST['timeofday'] == '17th') { ?> selected="selected" <?php } ?> >17th</option> <option value="18th" <?php if (isset($missing) && $_POST['timeofday'] == '18th') { ?> selected="selected" <?php } ?> >18th</option> <option value="19th" <?php if (isset($missing) && $_POST['timeofday'] == '19th') { ?> selected="selected" <?php } ?> >19th</option> <option value="20th" <?php if (isset($missing) && $_POST['timeofday'] == '20th') { ?> selected="selected" <?php } ?> >20th</option> <option value="21st" <?php if (isset($missing) && $_POST['timeofday'] == '21st') { ?> selected="selected" <?php } ?> >21st</option> <option value="22nd" <?php if (isset($missing) && $_POST['timeofday'] == '22nd') { ?> selected="selected" <?php } ?> >22nd</option> <option value="23rd" <?php if (isset($missing) && $_POST['timeofday'] == '23rd') { ?> selected="selected" <?php } ?> >23rd</option> <option value="24th" <?php if (isset($missing) && $_POST['timeofday'] == '24th') { ?> selected="selected" <?php } ?> >24th</option> <option value="25th" <?php if (isset($missing) && $_POST['timeofday'] == '25th') { ?> selected="selected" <?php } ?> >25th</option> <option value="26th" <?php if (isset($missing) && $_POST['timeofday'] == '26th') { ?> selected="selected" <?php } ?> >26th</option> <option value="27th" <?php if (isset($missing) && $_POST['timeofday'] == '27th') { ?> selected="selected" <?php } ?> >27th</option> <option value="28th" <?php if (isset($missing) && $_POST['timeofday'] == '28th') { ?> selected="selected" <?php } ?> >28th</option> <option value="29th" <?php if (isset($missing) && $_POST['timeofday'] == '29th') { ?> selected="selected" <?php } ?> >29th</option> <option value="30th" <?php if (isset($missing) && $_POST['timeofday'] == '30th') { ?> selected="selected" <?php } ?> >30th</option> <option value="31st" <?php if (isset($missing) && $_POST['timeofday'] == '31st') { ?> selected="selected" <?php } ?> >31st</option> </select> </td> <td> <select name="status" id="status" class="status"> <option value="<? echo $item['status']; ?>" <?php if (isset($missing) && $_POST['status'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['status']; ?></option> <option value="With Us" <?php if (isset($missing) && $_POST['status'] == 'us') { ?> selected="selected" <?php } ?> >With Us</option> <option value="With Client" <?php if (isset($missing) && $_POST['status'] == 'client') { ?> selected="selected" <?php } ?> >With Client</option> <option value="With Creative" <?php if (isset($missing) && $_POST['status'] == 'creative') { ?> selected="selected" <?php } ?> >With Creative</option> </select> <td> <td> <select name="importancy" id="importancy" class="importancy"> <option value="<? echo $item['importancy']; ?>" <?php if (isset($missing) && $_POST['importancy'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['importancy']; ?></option> <option value="1" <?php if (isset($missing) && $_POST['importancy'] == '1') { ?> selected="selected" <?php } ?> >Yes</option> <option value="0" <?php if (isset($missing) && $_POST['importancy'] == '0') { ?> selected="selected" <?php } ?> >No</option> </select> <td> <td class="gap"></td> <td><input type="image" name="submit" value="submit" style="margin-top: 4px; margin-right: 5px;" src="../images/sm-tick-box.jpg" class="save" alt="Save Edit" title="Save Row" /></td> <td><input type="image" style="margin-top: 0px; margin-right: 8px;" src="../images/delete_image.jpg" class="cancel" alt="Cancel Edit" title="Cancel Edit" ></td> </tr> </table></form> <?php } else { //display normal row ?> <div id="item_<?=$item['catid'];?>"> <p class="briefed"><?=$item['briefed'];?></p> <p class="job_number"><?=$item['job'];?></p> <p class="category"><?=$item['category'];?></p> <p class="needed"><?=$item['needed'];?> <?=$item['timeofday'];?></p> <p class="status"><?=$item['status'];?></p> <p class="order_id"><?=$item['orderid'];?></p> <p class="link"><a href="digital_asda.php?state=edit&catid=<?=$item['catid']?>"><img src="../images/edit_image.jpg" height="20" border="0" alt="Edit Row" title="Edit Row" /></a></p> <p class="delete"><a href="delete_row-digital.php?catid=<?=$item['catid']?>"><img src="../images/trash-empty.jpg" height="20" border="0" alt="Delete Row" title="Delete Row" /></a></p> </div> <? } } ?>
Any ideas on how I can do this?
-
Hi
I have a form, that has a hidden field. The hidden field is an email address called, original_email, which is the email address from the referer
The form, has fields such as name, email etc.
All the details are passed into a database, with 2 tables:
added_friends (id, name, email, entry_id, original_email) - is the table where, a second form details go (this is where fred@fredt.com can submit friends email addresses, such as fred@fredddd.com)
entries (id name, post_code, email, date_of_birth, last_visit, referer_id) - is the table where the form details are posted
What I'm looking to do, is:
1) The forms URL has the following passed: http://www.domain.com/index.php?name=craig&email=fred@fredt.com
2) Therefore the hidden field has a value of fred@fredt.com
3) User then changes his/her email address in the form to something else (i.e. fred@freddddd.com)
4) When user submits the form, his details are passed into the database.
5) fred@fredt.com has an id (e.g 25)
6) fred@freddddd.com has a refer_id column, which must be updated to include the id of fred@fredt.com (since he has refered him, so his refer_id will be 25)
7) fred@freddddd.com submits his details, his details are inserted into the db, check the added_friends table, get fred@fredt.com's id, insert this id into the entries table for fred@freddddd.com as the refer_id
My code is as follows:
<?php require(dirname(__FILE__) . "/shared.php"); class IndexView extends Shared { function display_form($error_messages = array()) { $this->html_top(); $this->_form($error_messages); $this->html_bottom(); } function _form($error_messages = array(), $unique_code = false) { ?> <?php if(count($error_messages)) { ?><ul id="errors"><?php foreach($error_messages as $error) { ?> <li><?=$error?></li> <?php } ?></ul><?php } ?> <table id="formReg"> <form id="pizza_form" name="pizza_form" action="index.php" method="post"> <tr> <td><input type="hidden" name="state" value="validate_submission"/></td> </tr> <tr> <td class="formLabel">Full name*</td> <td><?= create_input_field('', 'name', isset($_GET['name'])?$_GET['name']:'') ?></td> </tr> <tr> <td class="formLabel">Email*</td> <td><?= create_input_field('', 'email', isset($_GET['email'])?$_GET['email']:'') ?></td> </tr> <tr> <td></td> <td><a href="#" onclick="clear_out_name_and_email();">Not your details?</a></td> <tr> <td class="formLabel">Post Code*</td> <td><?= create_input_field('', 'post_code') ?></td> </tr> <tr> <td class="formLabel">Date Of Birth</td> <td><?= create_select_list('', 'dob_day', $options = $this->days_of_month_array() )?> <?= create_select_list('', 'dob_month', $options = $this->months_array() )?> <?= create_select_list('', 'dob_year', $options = $this->years_array() )?></td> </tr> <tr> <td></td> <td>We all like to celebrate birthdays...</td> </tr> <tr> <td class="formLabel">Last Pizza express visit</td> <td><?= create_select_list('', 'last_visit', $options = $this->visits_array() )?></td> </tr> <tr> <td><input type="hidden" name="unique_code" id="unique_code" value="<?=$unique_code?>"/></td> </tr> <tr> <td class="formLabel"><?= create_check_box('agree_terms', '', $checked=0, '') ?></td> <td>I have read and agree to the voucher <a href="#" title="terms and conditions" onclick="popTerms();">terms and conditions</a></td> </tr> <?php if(isset($_GET['email'])) { $orig_email = $_GET['email']; } elseif(isset($_POST['original_email'])) { $orig_email = $_POST['original_email']; } else { $orig_email = ''; } ?> <tr> <td><input type="hidden" name="original_email" id="original_email" value="<?=$orig_email?>"/></td> <td><input type="image" src="../images/btn-submit.gif" alt="Click here to print your voucher" onclick="onsubmit(); return false;" /></td> </tr> <?php } function display_voucher($row) { $this->html_top(); $row['id'] = 'AB140-2008-' . $row['id']; ?> <h1>Voucher for <?=$row['name']?></h1> <img src="barcode/wrapper.php?p_bcType=1&p_text=<?=$row['id']?>&p_xDim=2&p_w2n=3&p_charGap=2&p_invert=N&p_charHeight=60&p_type=1&p_label=Y&p_rotAngle=0&p_checkDigit=N" ALT="<?=$row['id']?>"> <br/> Email: <?=$row['email']?> <br/> Dob: <?=make_db_date_into_english_date($row['date_of_birth'])?> <br/> <?php $visit_array = $this->visits_array(); ?> Last Visited: <?=$visit_array[$row['last_visit']]?> <br/><br/> <?php echo create_link($params = array('state' => 'clear_session'), $file_name = 'index.php', $text = 'New Voucher'); ?> <br/> <a href="JavaScript:window.print();">Print this page</a> <h2>Forward this offer to up to 5 friends</h2> <?php if(isset($_GET['message']) && $_GET['message'] == 'friends_were_added') { ?><p>Thanks, we have emailed your friends</p><?php } else { ?> <form name="friend_form" method="post" action="index.php"> <input type="hidden" name="state" value="tell_friends"/> <input type="hidden" name="entry_id" value="<?=$row['id']?>"/> <?php for($i=1;$i<=5;$i++) { ?> <label for="friend_name_<?=$i?>">Friend <?=$i?> Name</label> <?= create_input_field('', "friend_name_$i") ?> <label for="friend_email_<?=$i?>">Friend <?=$i?> Email</label> <?= create_input_field('', "friend_email_$i") ?> <br/> <?php } ?> <input type="submit" value="submit"/> </form> <?php } $this->html_bottom(); } function days_of_month_array() { $r = array('' => ''); for($i=1;$i<=31;$i++) { $r[$i] = $i; } return $r; } function months_array() { $r = array('' => '', '1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => "May", '6' => 'Jun', '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); return $r; } function years_array() { $r = array('' => ''); for($i=1992;$i>1910;$i--) { $r[$i] = $i; } return $r; } function visits_array() { return array('' => '', 'last_fornight' => 'Within the last fortnight', 'last_month' => 'Within the last month', '6_months' => 'Within the last 6 months', 'over_1_year' => 'More that a year ago', 'first_time' => 'This is my first time'); } } ?>
Any ideas?
Thanks
-
I'm trying to implement postcode validation (UK) in a form I've wrote.
All works fine, If I include a space, e.g. AB12 3CD, but If I have the whole thing written as AB123CD, I can't get it to work and I get a validation error.
My code to display the error is as follows:
if(!str_replace(' ', '', $v->valid_postcode($data['post_code']))) { $errors[] = "You must enter a valid postcode"; }
Postcode validation function:
function valid_postcode($postcode) { $postcode = strtoupper($postcode); if(ereg("((GIR 0AA)|(TDCU 1ZZ)|(ASCN 1ZZ)|(BIQQ 1ZZ)|(BBND 1ZZ)" ."|(FIQQ 1ZZ)|(PCRN 1ZZ)|(STHL 1ZZ)|(SIQQ 1ZZ)|(TKCA 1ZZ)" ."|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]" ."|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))" ."|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2})", $postcode)) { return $postcode; } else { return FALSE; }
I want it, so no matter what I type, AB12 3CD or AB123CD, it lets me use this.
Any ideas where I'm going wrong?
Thanks
-
Hi
I have a script, which I want to use the contents of as an RSS feed onto my Google homepage.
The content will change on a daily basis.
What's the easiest way of doing this?
Thanks
-
Hi
I'm using the tutorial found at: http://www.gregphoto.net/index.php/2007/01/ and the demo can be found at: http://www.gregphoto.net/projects/scriptaculous17/
I've changed the layout, so the page now looks like: http://www.craigwillis-online.co.uk/priority/index.php
As you can see, there is a number associated with each row. When you drag and drop a row, the data is saved to the database. You have to refresh the page to update the priority number.
What I'm looking to do is when the row has been dropped, the number (Priority) updates automatically, rather than the user refreshing the page.
Is there any javascript that could do this?
The script uses the Prototype javascript framework
Thanks
-
Hi
I have a domain, which when I type in the http://www it goes straight to the site and points at the correct directory.
But when I point domain.co.uk it points to the old folder where the /var/www/site_old docs used to be.
I have /var/www/site_new where http://www.domain.co.uk points to, yet domain.co.uk doesn't.
My apache vhosts for the site are below.
<VirtualHost www.domain.co.uk:80>ServerAdmin domain@domain.com
ServerName www.domain.co.uk
ServerAlias bullbrand.co.uk
DocumentRoot /var/www/site_new
<Directory />
Options FollowSymLinks
# AllowOverride None
</Directory>
<Directory /var/www/site_new>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
<VirtualHost www.domain.co.uk:443>
ServerAdmin domain@domain.com
ServerName www.domain.co.uk
ServerAlias domain.co.uk
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/www_domain_co_uk.crt
SSLCertificateKeyFile /etc/apache2/ssl/www.domain.co.uk.key
SSLCertificateChainFile /etc/apache2/ssl/www_domain_co_uk.ca-bundle
DocumentRoot /var/www/site_new
<Directory />
Options FollowSymLinks
# AllowOverride None
</Directory>
<Directory /var/www/site_new>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
Nothing in what you can see above points anything to /var/www/site_old
So I'm really confused as to why this is happening.
I've tried to redirect domain.co.uk to http://www.domain.co.uk but it hasn't worked
Any ideas?
-
Any idea how I'd use that within my code?
-
Hi
I have a news page, which lists the news items in the database on a page.
I have an admin page, which I can add a news story, and make it 'Active' or 'Archived'
As I don't have any arcvhived news stories yet, I want it to hide the <h4></h4> that is displayed and then below that is the 'Archived News'
My code so far is:
<?php $stories = get_news_stories(); global $db; while($one_row = $db->db_fetch($stories)) { ?> <h4><?=$one_row['title']?></h4> <div style="float: right; margin-top: -20px; color: #000000; font-size: 14px; "><? echo date("d-m-Y",strtotime($one_row['date'])) ?></div> <p class="news" ><?=$one_row['description']?></p> <?php } ?> <h4 class="header">News Archive</h4> <?php $stories = get_news_stories_archived(); global $db; while($one_row = $db->db_fetch($stories)) { ?> <table border="0" width="650" style="margin-left: 7px;" class="archive"> <tr> <td class="archive"><a href="news-archive.php?id=<?=$one_row['id']?>" style="text-align: center; "><? echo substr($one_row['title'],0,60) . '..'; ?></a></td> <td width="100" style="text-align: right; font-size: 12px; color: #fffff; "><? echo date("d-m-Y",strtotime($one_row['date'])) ?></td> </tr> </table> <div style="border-bottom: 1px solid #666; margin-top: 8px; margin-left: 5px;"></div> <?php } ?>
you can see there is the <h4> for the Archived News. So far, this is always displayed, but I want it to display only when there is a story that has been flagged as 'Archived'
2 functions:
get_news_stories_archived()
function get_news_stories_archived($include_archived = true) { global $db; $include_archived?$sql_where="status != 0 and status != 1":$sql_where="status = 2"; $sql = " SELECT * FROM news WHERE $sql_where ORDER BY sort_order ASC "; $result = $db->db_query($sql); return $result; }
function get_news_stories($include_archived = false) { global $db; $include_archived?$sql_where="status != 0":$sql_where="status = 1"; $sql = " SELECT * FROM news WHERE $sql_where ORDER BY sort_order ASC "; $result = $db->db_query($sql); return $result; }
How will I achieve what I'm looking to do with the code I've supplied?
Thanks
-
Hi
After a couple of hours of wasted time on the Zen Cart forums I decided to come here for some advice.
when a customer buys a products they are sent a order confirmation email.
At the bottom of this, I want to add a section about the Returns Policy, which includes a URL to our Returns Policy on the website.
The only proble I have, is that the URL isn't displaying properly.
My define() code is found in "includes/languages/english/email_extras.php":
define('EMAIL_DISCLAIMER', 'Returns Policy' . "\n\n" . 'If you are not completely satisifed with your purchase for any reason, simply return the product to us in its original condition, including all original packaging and documentation, within 30 days of receipt to ADDRESS.' . "\n\n" . 'If the goods are returned as detailed above, we will issue a full refund for the price paid for the item, or exchange the item for another product. <a href="http://www.example.com/index.php?main_page=terms">Click here</a> to read the full policy');
But the output in the email is:
Returns PolicyIf you are not completely satisifed with your purchase for any reason,
simply return the product to us in its original condition, including all
original packaging and documentation, within 30 days of receipt to ADDRESS.
If the goods are returned as detailed above, we will issue a full refund for
the price paid for the item, or exchange the item for another product.Click
here to read the full policy
Any ideas what I need to change to get the URL working?
Thanks
-
Hi
I have a script that takes data from a database and outputs the rows into a CSV file.
The only problem I have is that it removes the leading '0' from the telephone number if the telephone number in the database is in the format 01234567890 (returns: 1234567890), but if the number
is in the format 01234 567890(returns 01234 567890) it outputs the leading '0'.
The field in the database is a varchar(255)
This is the code I have to create the CSV
<?php require_once('functions.php'); $users_result = get_users_result($page = 0);//get all $fields = mysql_num_fields($users_result); $csv_output = ''; $data = ''; for ($i = 0; $i < $fields; $i++) { $csv_output .= mysql_field_name($users_result, $i) . "\t"; } while($row = mysql_fetch_row($users_result)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=subscribers.xls"); header("Pragma: no-cache"); header("Expires: 0"); print $csv_output."\n".$data; exit; ?>
and the function get_users_result:
function get_users_result($page) { /*if you pass in a page, it will limit the number of records. Pass in 0 to bypas this and get all records*/ $per_page = PAGINATION_NUMBER_PER_PAGE; if($page > 1) { $shown_already = $per_page*($page-1); $limit_start = $shown_already; $limit_sql = " LIMIT $limit_start, $per_page "; } elseif(!$page) { $limit_sql = ''; } else { $limit_sql= " LIMIT 0, $per_page "; } $sql="SELECT name, email, organisation, telephone, message, subscribe FROM contacts ORDER BY id $limit_sql "; $result = mysql_query($sql); return $result; }
Any help appreciated.
Thanks
-
Hi
I've got a horizontal news scroller on my site, which works fine in FireFox and IE7, but once the the text has scrolled on IE 6, it stops and doesn't scroll from the beginning.
My code is:
//Specify the marquee's width (in pixels) var marqueewidth="265px" //Specify the marquee's height var marqueeheight="105px" //Specify the marquee's marquee speed (larger is faster 1-10) var marqueespeed=2 //configure background color: var marqueebgcolor="none" //Pause marquee onMousever (0=no. 1=yes)? var pauseit=1 //Specify the marquee's content (don't delete <nobr> tag) //Keep all content on ONE line, and backslash any single quotations (ie: that\'s great): var marqueecontent='<nobr><p><a href="recruitment/product_trainer.html">Product Trainer</a> <a href="recruitment/key_account_manager.html">Key Account Manager</a> <a href="recruitment/lead_generator.html">Lead Generator</a> <a href="recruitment/database_analyst.html">Database Analyst</a> <a href="recruitment/new_business_development_manager.html">New Business Development Manager</a> <a href="recruitment/software_developer.html">Software Developer</a> <a href="recruitment/database_developer.html">Database Developer</a> <a href="recruitment/business_analyst.html">Business Analyst</a> <a href="recruitment/sales_marketing_executive.html">Sales & Marketing Executive</a></p></nobr>' ////NO NEED TO EDIT BELOW THIS LINE//////////// marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS var copyspeed=marqueespeed var pausespeed=(pauseit==0)? copyspeed: 0 var iedom=document.all||document.getElementById if (iedom) document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>') var actualwidth='' var cross_marquee, ns_marquee function populate(){ if (iedom){ cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee cross_marquee.style.left=parseInt(marqueewidth)+8+"px" cross_marquee.innerHTML=marqueecontent actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth } else if (document.layers){ ns_marquee=document.ns_marquee.document.ns_marquee2 ns_marquee.left=parseInt(marqueewidth)+8 ns_marquee.document.write(marqueecontent) ns_marquee.document.close() actualwidth=ns_marquee.document.width } lefttime=setInterval("scrollmarquee()",20) } //window.onload=populate function scrollmarquee(){ if (iedom){ if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+) cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px" else cross_marquee.style.left=parseInt(marqueewidth)+8+"px" } else if (document.layers){ if (ns_marquee.left>(actualwidth*(-1)+) ns_marquee.left-=copyspeed else ns_marquee.left=parseInt(marqueewidth)+8 } } if (iedom||document.layers){ with (document){ document.write('<p>') if (iedom){ write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">') write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">') write('<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>') write('</div></div>') } else if (document.layers){ write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>') write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>') write('</ilayer>') } document.write('</p>') } }
Any ideas why this is? Or can someone show me a good script that works in all browsers?
Thanks
-
Is there any way that I can make it so that when I'm updating a row, it updates it based on it's catid?
I thought having a hidden field would maybe help?
-
Hi
I have a form, which i want to update a row's details in a mysql database
My form is:
echo '<form action="save.php" name="insert_priority" METHOD="post">'; echo '<table>'; echo '<input type="hidden" name="briefed"'; {echo "value=\"" . $_POST['catid'] . "\"";}echo ' />'; echo '<td><input class="briefed" type="text" name="briefed"'; if(isset($_POST['briefed'])){echo "value=\"" . $_POST['briefed'] . "\"";}echo ' /></td>'; echo '<td><input class="job" type="text" name="job"'; if(isset($_POST['job'])){echo "value=\"" . $_POST['job'] . "\"";}echo ' /></td>'; echo '<td><input class="category" type="text" name="category"'; if(isset($_POST['category'])){echo "value=\"" . $_POST['category'] . "\"";}echo ' /></td>'; echo '<td><input class="needed" type="text" name="needed"'; if(isset($_POST['needed'])){echo "value=\"" . $_POST['needed'] . "\"";}echo ' /></td>'; echo '<td><input class="status" type="text" name="status"'; if(isset($_POST['status'])){echo "value=\"" . $_POST['status'] . "\"";}echo ' /></td>'; echo '<td class="gap"></td>'; echo '<td class="gap"></td>'; echo '<td class="save"><input type="image" style="margin-top: 4px;" src="images/sm-tick-box.jpg" height="20" class="save" alt="Submit "> </td>'; echo '</table>'; echo '</form>';
and the code to update the row is:
$sql = "UPDATE Categories SET (briefed = '$briefed', job ='$job', category ='$category', needed ='$needed', status ='$status', orderid ='') WHERE catid = $catid )"; mysql_query($query);
I get the following errors:
string(145) "UPDATE Categories SET (briefed = 'PP', job ='PP', category ='PPPPPPPPPPPPPPPPPPPPPPPP', needed ='PP', status ='PP', orderid ='') WHERE catid = )" Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(briefed = 'PP', job ='PP', category ='PPPPPPPPPPPPPPPPPPPPPPPP', needed ='PP', ' at line 1Do I need to change both the way the form accepts input and my SQL statement to achieve this?
Thanks
-
I used this:
<p class="delete"><a href="delete_row.php?catid=<?=$item['catid']?>">delete</a></p>
Worked perfectly
-
Hi
I have a for loop that outputs info from my database.
I want next to each to have a link with a delete button, when clicked, the row gets deleted, based on the 'catid'
My code is as follows:
foreach($list as $item) { if(isset($_GET['state']) && $_GET['state'] == 'edit' && $_GET['id'] == $item['catid']) { ///display row with values inside form fields } else { //display normal row ?> <div id="item_<?=$item['catid'];?>"> <p class="briefed"><?=$item['briefed'];?></p> <p class="job_number"><?=$item['job'];?></p> <p class="category"><?=$item['category'];?></p> <p class="needed"><?=$item['needed'];?></p> <p class="status"><?=$item['status'];?></p> <p class="order_id"><?=$item['orderid'];?></p> <p class="link"><a href="index.php?state=edit&catid=<?=$item['catid']?>">Edit</a></p> <p class="delete"><a href="delete_row.php"></a><img src="images/cross.png" border="0" /></a></p> </div> <? } } ?>
Anyone know what I need to add tot the delete section and what needs to be in delet_row.php?
Thanks
-
whoops! sorry
-
Hi
I'm trying to implement an edit-in place functionality to a script i have.
The script so far, takes information from a database, and outputs this as a drag and drop table.
What I'm looking to do, is to be able to edit a row and save the changes, which updates the database details and also, a way of deleting a row, if it's no longer needed.
The script currently uses both prototype and scriptaculous javascript frameworks.
My code so far:
<? require('db.php'); $demo = new SortableExample(); $list = $demo->getList(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Online Priority List - <?php echo date("l F j Y");?></title> <link rel="stylesheet" type="text/css" href="style.css"> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style_ie7.css"> <![endif]--> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="style_ie6.css"> <![endif]--> <script src="js/prototype.js"></script> <script src="js/scriptaculous.js"></script> <script> Event.observe(window,'load',init,false); function init() { Sortable.create('listContainer',{tag:'div',onUpdate:updateList}); } function updateList(container) { var url = 'ajax.php'; var params = Sortable.serialize(container.id); var ajax = new Ajax.Request(url,{ method: 'post', parameters: params, onLoading: function(){$('workingMsg').show()}, onLoaded: function(){$('workingMsg').hide()} }); } </script> </head> <body> <h2>Online Priority List - <?php echo date("l F j Y");?></h2> <table> <td class="briefed">Briefed By:</td> <td class="job">Job No.</td> <td class="category">DIGITAL</td> <td class="needed">Needed By:</td> <td class="status">Status</td> <td class="priority">Priority</td> </table> <div id="listContainer"> <? foreach($list as $item) { ?> <div id="item_<?=$item['catid'];?>"><p class="briefed"><?=$item['briefed'];?></p><p class="job_number"><?=$item['job'];?></p><p class="category"><?=$item['category'];?></p><p class="needed"><?=$item['needed'];?></p><p class="status"><?=$item['status'];?></p><p class="order_id"><?=$item['orderid'];?></p></div> <? } ?> </div> <div id="workingMsg" style="display:none;">Updating database...</div> <a href="addRow.php"><img src="images/add_button.jpg" height="30" border="0"/></a> </body> </html>
<? session_start(); require_once('db.php'); $demo = new SortableExample(); $demo->updateList($_POST['listContainer']); ?>
An image of what it looks like can be found below:
Thanks
-
Well I'd rather stay away from putting the file name explicitly in the array, as this script is going to be running daily, on a cron, so I'd rather not have need to keep adding file names into the array
I'll have a look at it, and keep trying.
-
Can anyone help?
Please
-
Hi thanks for that.
I've changed my code and got the FTP connection out of the loop.
<?php require_once('config.php'); require_once('dbconn.php'); start_trace('run.php'); function run() { $fct_name = 'run'; function_start($fct_name); $up_to_date = false; // db select $result = mysql_query("SELECT date FROM csv_files ORDER BY date DESC LIMIT 0, 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); $last_inserterd_date = $row['date']; debug("LAST INSERTED [$last_inserterd_date]"); $next_date = date('Y-m-d', (strtotime($last_inserterd_date)+ 86400)); debug(" NEXT DATE IS [$next_date]"); if ($next_date == date('Y-m-d')) { $up_to_date = true; } else { // connect to FTP $ftp_server = "www.example.com"; $ftp_user_name = "password"; $ftp_user_pass = "password"; $fromDir = "folder/"; $toDir = "/Users/mac/workspace/test_csv/download/"; // Connected, else throw an exception $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if((!$conn_id) || (!$login_result)) { echo "Could not Connect to the FTP Server"; exit(); } } while(!$up_to_date) { $file_to_search_for = "File_" . date('Ymd', strtotime($next_date)) . ".txt"; debug("The file to search for is [$file_to_search_for]"); //check FTP for date $file_to_search_for //if file exists //download file and run // //set $next_date to be $next_date + 1 day // if $next_date > today $up_to_date = true; //end } function_end($fct_name); } run(); end_trace('run.php'); ?>
I've added in some debug, so I can see what the date is of the last inserted date and the next date.
You can see what I'm trying to do, in the while loop. See the comments.
But I'm not sure how to do that.
Any ideas?
-
Ok.
I'm still stuck with this.
I've done a bit more code
$result = mysql_query("SELECT date FROM csv_files ORDER BY date DESC LIMIT 0, 1") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $last_inserterd_date = $row['date']; // echo "LAST INSERTED [$last_inserterd_date]<br>"; $next_date = date('Y-m-d', (strtotime($last_inserterd_date)+ 86400)); // echo " NEXT DATE IS [$next_date]"; echo $last_inserterd_date_for_ftp = str_replace("-", "", $last_inserterd_date); // connect to FTP $ftp_server = "www.example.com"; $ftp_user_name = "username"; $ftp_user_pass = "password"; $fromDir = "folder/$last_file"; $toDir = "/Users/mack/workspace/test_csv/download/"; // Connected, else throw an exception $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if((!$conn_id) || (!$login_result)) { echo "Could not Connect to the FTP Server"; exit(); } // array of the files $contents = ftp_nlist($conn_id, $fromDir); sort($contents); // hard-coded until I get the file from the array from FTP $string = 'File_20080611.txt'; if (strstr($string,$last_inserterd_date_for_ftp)) { // run the download funuction? echo 'Found'; } else { echo 'Not found'; } }
Here, I'm trying to find a string, within the array that is created with all the files on the FTP.
Trying to see If I can find $last_inserterd_date_for_ftp (which outputs as 20080611) within the $contents array, which works.
But, I'll need to dynamically find $string as it can't be hard-coded. This is where i need to loop round, and find the next date, 20080612, and see if it matches within the array etc etc
-
I know how to download a file from FTP
My only issue, is the loop so far, how to loop through the files on the ftp server, and check the date on them with the rows in the database.
My code so far is
while($row = mysql_fetch_array( $result )) { $last_inserterd_date = $row['date']; echo "LAST INSERTED [$last_inserterd_date]<br>"; $next_date = date('Y-m-d', (strtotime($last_inserterd_date)+ 86400)); echo " NEXT DATE IS [$next_date]"; }
So far $next_date only returns the date after, I need to use this to loop through.
I have a date in the database from 11th june, I have 6 files dated 13th june, 17th june, 18th june, 19th june, 24th june, 26th june, 27 june, 30th junand 1st july on the FTP server
I've got the last date in the database, which is the 11th june. So what I'm looking to do, is loop through and find the next date, if there's no 12th june, loops through and finds 13th june, downloads the file named File_20080613 and runs the function to process the contents and then this gets inserted into the database(the script does the insertion)
Once the 13th june has been processed, it loops through again, if 14th june is found downloads, if not, loops through, until it gets to 17th and the whole process starts again, until it gets to todays date. The loop should have someway of exiting, for example, if $next_date is greater than todays date, it should exit.
I know this sounds complicated, but i just need to be able to loop through.
Thanks
-
That would be great, but I'd prefer to write in PHP.
Have you got an example similar to what I'm after but written in PHP?
Thanks
Calling a PHP script in bash
in Linux
Posted
I used this:
Seemed to work fine
I needed the php -f to call php