Jump to content

bob_the _builder

Members
  • Posts

    206
  • Joined

  • Last visited

Everything posted by bob_the _builder

  1. Hi, that is all the code relevant.. other than the ajax in the link from the first post.. That ajax code is only designed to work with get. I manage to get it to work but can only pass one variable across using get and OnSubmit: <form name="addsubcat" method="get" action="javascript: AjaxRequest(\'main\',\'./includes/gallery.php?action=addsubcat\')" OnSubmit="javascript: AjaxRequest(\'main\',\'./includes/gallery.php?action=addsubcat&subcatname=\',\'subcatname\')"> <b>Add Sub Category:</b><br /><br /> Select Main Category:<br /><br /> <select id="maincatid" name="maincatid"> <option value="">Choose</option>'; $sql = mysql_query("SELECT * FROM gallerymaincat ORDER BY maincatname ASC"); while ($row = mysql_fetch_array($sql)) { echo '<option value="'.$row['maincatid'].'">'.stripslashes($row['maincatname']).'</option>'; } echo '</select><br /><br /> Type category name:<br /><br /> <input type="text" id="subcatname" name="subcatname" /><br /><br /> <input type="submit" value="submit" name="submit"> </form> Most of the variables are pased across the url, but have a few forms as well. Is there away to pass more variables with the form? Thanks
  2. Hi, I am using the ajax example from here When I use the ajax request in a form no post data seems to be generated, have is missed something? <form name="maincat" action="javascript: AjaxRequest(\'main\',\'./includes/gallery.php?action=addmaincat\')" method="post"> <input name="maincat" type="hidden" value="maincat" /> <input type="text" name="maincatname" /><br /><br /> <input type="submit" value="Submit" name="Submit"> </form> Thanks
  3. Hi, Is there away to use something like href="#" onClick="history.go(-1)" to move back a page within ajax div tags? Thanks
  4. Here is the cart code, But im not sure of a simple way to check the delivery code and bed size to grab the correct freight rate for each procuct. Trying to get a match to the town and bed size for the freight on each product without a ton is if statements code 1 small = $80, king single = $95, double = $120, queen = $136, king = $152 code 2 small = $110, king single = $125, double = $165, queen = $187, king = $209 code 3 ...... if(!$empty) { $query = 'SELECT p.*, h.* FROM products as p JOIN headings as h ON h.headingid = p.headingid WHERE itemid IN ('; foreach($_SESSION['cart'] as $key => $value) { $query .= $key . ','; } $query = substr ($query, 0, -1) . ') ORDER BY itemid ASC'; $result = mysql_query($query); // Explode list menu $selec = explode(",", $_POST['location']); // Session register code for freight location session_register('location'); $_SESSION['location'] = $selec[1]; if(($_SESSION['location'] == 1) && ($description == Single)){ $freight = '80'; } echo '<form name="cart" action="'.$_SERVER['PHP_SELF'].'" method="post"> <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td align="left"><b>Code</b></td> <td width="380" align="left"><b>Product Name</b></td> <td width="162" align="right"><b>Price</b></td> <td width="143" align="center"><b>Qty</b></td> <td colspan="2" align="right"><b>Sub Total</b></td> </tr> <td width="207">'; $total = 0; while ($row = mysql_fetch_array ($result)) { foreach($row as $key=>$value){ $$key = ValidateInput($value); } $subtotal = $_SESSION['cart'][$itemid] * $price; $total += $subtotal; $qty = $_SESSION['cart'][$itemid]; $totalqty += $qty; $totalweight = $_SESSION['cart'][$itemid] * $weight; $subfreight += $totalweight; // Old basic freight system $totalfreight = $subfreight * $perkg; $ntotal = $total + $totalfreight; session_register('total'); $_SESSION['total'] = number_format($total, 2); session_register('qty'); $_SESSION['qty'] = $qty; session_register('totalqty'); $_SESSION['totalqty'] = $totalqty; echo '</td> <tr> <td align="left">'.$code.'</td> <td align="left">'.$heading.' '.$name.'</td> <td align="right">$'.$price.'</td> <td align="center"><center> <input type="text" size="3" name="qty['.$itemid.']" value="'.$_SESSION['cart'][$itemid].'" /> </center></td> <td colspan="2" align="right">$'.number_format($subtotal, 2).'</td> </tr>'; } echo '<tr> <td colspan="4" align="right">'; // Creates array of towns and its freight code $cities = array('Pickup (Local)' => '1', 'town1' => '2', 'town2' => '2', 'town3' => '2', 'town4' => '2', 'town5' => '2', 'town6' => '3', 'town7' => '3', 'town8' => '4', 'town9' => '4', 'town' => '4'); // List menus of towns echo '<select name="location" onChange="this.form.submit();"> <option value="" selected>Select Location</option>'; foreach($cities as $key => $value) { echo '<option '.( $key==$selec[0] ? 'selected' : '' ).' value="'.$key.','.$value.'">'.$key.'</option>'; } echo '</select> </td> <td align="right"><b>Freight:</b></td> <td align="right">'.number_format($totalfreight,2).'</td> </tr> <tr> <td colspan="3" align="right"> </td> <td align="right"> </td> <td width="106" align="right"><b>Total:</b></td> <td width="75" align="right"><b><font color="FF0000">$'.number_format($ntotal,2).'</font></b></td> </tr> <tr> <td colspan="3" align="right"> </td> <td colspan="3" align="right"><br /><input type="submit" name="Submit" value="Update Cart"></td> </tr> </table> </form> <br /> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="8" align="right"><img src="images/black_arrow.gif" width="11" height="13"> <b><a href="./index.php?action=shop">Continue Shopping</a> <img src="images/black_arrow.gif" width="11" height="13"> <a href="./cart.php?action=custdetails">Checkout</a></b></td> </tr> </table>'; }else{ echo '<br /><center>Your cart is currently empty.</center><br />'; } Thanks
  5. Hi, I have a shoping cart thats holds products (beds) which range from small, king single, double, queen, king. There are 5 codes depending on the area of delivery (freight). So ... code 1 small = $80, king single = $95, double = $120, queen = $136, king = $152 code 2 small = $110, king single = $125, double = $165, queen = $187, king = $209 code 3 ...... The code is selected while in the cart and set as a session variable. How can I get the freight value for each product dependant code selected and what size the bed is? Thanks
  6. Hi, My bad, I thought you wanted to exclude any records = to 5 so you want a simple query then: $q = "SELECT username, userlevel, email, num_clicks ,timestamp ,realname, phone FROM tbl_users WHERE userlevel = 5"; That will return only records where userlevel is equal to 5. hth
  7. Hi, That query should leave out any records with the userlevel of 5. $q = "SELECT username, userlevel, email, num_clicks ,timestamp ,realname, phone FROM tbl_users WHERE userlevel <> 5 ORDER BY userlevel DESC"; Try the query above and also formatting yer querys something like above, cleaner and easy to read. hth
  8. Hi, I beleave WHERE comes before ORDER BY ..
  9. Hi, I guess you are allready quering the database .. So maybe something like if ($imagefield == '') { echo 'No Banner'; }else{ echo 'Link to banner here'; } hth
  10. Hi, Try WHERE userlevel <> '5'
  11. Hi, I have this code above the form: if(isset($_GET['prev'])){ if($_GET['prev'] == 'prev') { $monthnum = $_GET['monthnow']--; }else{ $monthnum = $_GET['monthnow']++; } $date = getdate(mktime(0,0,0,$_GET['monthnow'],1,$_GET['yearnow'])); }else{ $date = getdate(); } if((isset($_GET['pge'])) || (isset($_GET['all']))){ $monthnum = $_GET['monthnow']; $date = getdate(mktime(0,0,0,$_GET['monthnow'],1,$_GET['yearnow'])); } $monthnum = $date['mon']; $monthname = $date['month']; $year = $date['year']; $datetoday = getdate(mktime(0,0,0,$monthnum,1,$year)); $firstweekay = $datetoday['wday']; $cont = true; $today = 27; if(!isset($_GET['appt'])){ $appt = date("Y-m-d"); }else{ $appt = $_GET['appt']; } while(($today <= 32) && ($cont)) { $datetoday = getdate(mktime(0,0,0,$monthnum,$today,$year)); if($datetoday['mon'] != $monthnum) { $lastday = $today - 1; $cont = false; } $today++; } $day only hold the day as its value. In the database when an appointment is added it gets stored under "startdate" field as date/time. Basically trying to find $today value and days that match $startdate. Just have no idea how .. have tried a few ways but no success, just changes all the boxes with either or colour. Thanks
  12. Hi, Yer, I have tried so many ways to make it happen, but cant get the logic right. Thats was just what was there when I copied and pasted the code. Any ideas on the general concept to make it happen? Thanks
  13. Hi, I have the following script, but I cant make it highlight days that contain events or the current day in a different colour.. How would I go about adding such features? <form action="../calendar.php" method="get"> <table width="160" align="center" border="1" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#ffffff"> <tr> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Sun</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Mon</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Tue</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Wed</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Thu</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Fri</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Sat</b></td> </tr> '; $day = 1; $wday = $firstweekay; $firstweek = true; while ($day <= $lastday) { if($firstweek) { echo '<tr>'; for ($i=1; $i<=$firstweekay; $i++) { echo '<td></td>'; } $firstweek = false; } if ($wday==0) { echo '<tr>'; } if(intval($monthnum) < 10) { $newmonthnum = '0'.$monthnum.''; } elseif (intval($monthnum) >= 10) { $newmonthnum = $monthnum; } if(intval($day) < 10) { $newday = '0'.$day.''; } elseif(intval($day) >= 10) { $newday = $day; } $link_date = "$year-$newmonthnum-$newday"; if($day == $day){ $color = "#CCFFCC"; }else{ $color = "#FFFFCC"; } echo '<td style="padding: 6px" align="center" bgcolor="'.$color.'"><a href="calendar.php?pge&monthnow='.$monthnum.'&yearnow='.$year.'&add='.$_GET['add'].'&appt='.$link_date.'">'.$day.'</a></td>'; if($wday==6) { echo '</tr>'; } $wday++; $wday = $wday % 7; $day++; } echo ' </table> </form> Thanks
  14. Hi, I added the $ to the i, no difference. if I echo the following within the processtrans case the only result I get back is the $total variable: echo ''.$_POST['firstname'][$i].' '.$_POST['lastname'][$i].' - '.$_POST['emailaddress'][$i].' '.$total.'<br />'; The from could hold 3 records, but I only submit totals for 2 of the records and post the form the result I get from the above echo is: - 1.00 - 3.00 So each variable as $_POST['firstname'][$i] etc are empty. I need to loop thru each record in the form and email the data from each record to the matching email address. ? Thanks
  15. Hi, I now have the following but .. all variables formated as $_POST['lastname'][$i] dont hold any data, altho $total still holds the correct data? case 'showtrans': echo '<form name="trans" method="post" action="'.$_SERVER['PHP_SELF'].'?action=processtrans"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">'; $sql = mysql_query("SELECT * FROM cctrans ORDER BY firstname ASC"); while($row = mysql_fetch_array($sql)) { foreach($row as $key=>$value){ $$key = ValidateOutput($value); } echo '<tr> <td width="40%">'.$firstname.' '.$lastname.' - Total = <b>$'.$total.'</b></td> <td width="60%">Total including freight + 4% <input name="total[]" type="text" size="10"></td> </tr>'; } echo '<tr> <td colspan="2" align="right"> <input type="hidden" name="method[]" value="'.$method.'"> <input type="hidden" name="firstname[]" value="'.$firstname.'"> <input type="hidden" name="lastname[]" value="'.$lastname.'"> <input type="hidden" name="emailaddress[]" value="'.$emailaddress.'"> <input type="hidden" name="transid[]" value="'.$transid.'"> <input type="submit" name="Submit" value="Submit"> </td> </tr> </table> </form>'; break; case 'processtrans': echo '<b>Successfully emailed out the following totals including freight to:</b><br /><br />'; $sql = mysql_query("SELECT companyname, companyemail FROM company WHERE companyid = 1"); while ($row = mysql_fetch_array($sql)) { $companyname = $row['companyname']; $companyemail = $row['companyemail']; } foreach(array_filter($_POST['total']) as $i=>$total){ // Set payment choice to email client if ($_POST['method'][i] == 'Direct Credit') { $payment = 'Please deposit the sum of: <b>$'.$total.'</b>nzd, incl gst into the following Bank Account: <br /><br /> $companyname <br /><br /> $bank <br /><br /> <b>Acc No:</b> $account'; } if ($_POST['method'][i] == 'Cheque') { $payment = 'Please post a cheque to the sum of: <strong>$'.$total.'</strong>nzd incl gst crossed and made payable to: <br /><br /> $companyname <br /><br /> $address'; } if ($_POST['method'][i] == "Paypal") { $payment = 'Please <a href="http://www.test.com/paypal.php?order=order&firstname='.$_POST['firstname'][i].'&lastname='.$_POST['lastname'][i].'&email='.$_POST['emailaddress'][i].'&total='.$total.'">CLICK HERE</a> to complete your order'; } // Mail Client $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: $companyname <$companyemail>\r\n"; $headers .= "Reply-To: $companyemail <$companyemail>\r\n"; $to = "".$_POST['firstname'][$i]." ".$_POST['lastname'][$i]." <".$_POST['emailaddress'][$i].">"; $subject = "$companyname order confirmation"; $message = 'Hi '.$_POST['firstname'][$i].', <br /><br /> Your new total including freight is: <b>$'.$total.'</b> <br /><br /> '.$payment.' <br /><br /> Regards <br /><br /> The Team @ '.$companyname.''; mail($to, $subject, $message, $headers); echo ''.$_POST['firstname'][$i].' '.$_POST['lastname'][$i].' - '.$_POST['emailaddress'][$i].' '.$total.'<br />'; } Thanks
  16. Hi I have made a script to show how many people on line and the most users at one time: <?php putenv("TZ=Pacific/Auckland"); $insertdate = date('Y-m-d H:i:s'); $limit_time = time() - 300; if(!session_is_registered('online')){ mysql_query("INSERT INTO ppl_online (session_id, activity, ip_address, refurl, user_agent) VALUES ('".session_id()."', '$insertdate', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['HTTP_REFERER']."', '".$_SERVER['HTTP_USER_AGENT']."')"); session_register('online'); } if(session_is_registered('online')){ mysql_query("UPDATE ppl_online SET activity='$insertdate' WHERE session_id='".session_id()."'"); } $inactive = time() - 1800; mysql_query ("DELETE FROM ppl_online WHERE UNIX_TIMESTAMP(activity) < $inactive"); $total = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time GROUP BY ip_address"); $totalonline = mysql_num_rows($total); $most = mysql_query("SELECT * FROM most_users"); while($row = mysql_fetch_array($most)){ $most_users = $row['total']; $most_date = date('D dS M Y, h:i a', strtotime($row['date'])); } if ($totalonline > $most_users) { $sql = mysql_query("UPDATE most_users SET total='$totalonline', date='$insertdate' WHERE id=1"); } ?> Since adding: putenv("TZ=Pacific/Auckland"); $insertdate = date('Y-m-d H:i:s'); To the script it seems to total all the users that have been online even it it was 10 minutes ago. How can I fix this? Thanks
  17. Hi, Thanks, that code generates a query error. Im not sure if I should be using one query or 2? Is it explained well enough for what I am trying to acheive? Cheers
  18. Hi, I am writing a basic forum. I am struging to grab the last poster for display in the forum index. My table layout is: CREATE TABLE headings ( headingid int(5) NOT NULL auto_increment, heading varchar(50) NOT NULL, description varchar(255) NOT NULL, PRIMARY KEY (headingid) ); CREATE TABLE topics ( topicid int(5) NOT NULL auto_increment, headingid int(5) NOT NULL, userid int(5) NOT NULL, views int(5) NOT NULL, topic varchar(50) NOT NULL, PRIMARY KEY (topicid) ); CREATE TABLE posts ( postid int(5) NOT NULL auto_increment, topicid int(5) NOT NULL, userid int(5) NOT NULL, Post text NOT NULL, added datetime NOT NULL, viewed int(5) NOT NULL, PRIMARY KEY (postid) ); On the page where the headings are displayed I am trying to show the last poster for each heading. I have tried with no luck, here is what I have at the moment which is no where near correct: $sql = mysql_query("SELECT u.first_name, u.first_name, p.added FROM topics as t LEFT JOIN posts as p ON t.topicid = p.topicid LEFT JOIN users as u ON u.userid = p.userid LEFT JOIN headings as h ON h.headingid = t.headingid WHERE t.headingid = h.headingid ORDER BY t.topicid DESC LIMIT 1") or die (mysql_error()); while ($row1 = mysql_fetch_array($sql)) { $sql = mysql_query("SELECT * FROM headings"); while ($row = mysql_fetch_array($sql)) { Thanks
  19. Hi, Na seems to work fine. I have never used sms before, was just wanting to be sure it is a plausible way to go about it. Thanks
  20. $user = '###'; $password = '###'; $api_id = '###'; $baseurl ='http://api.clickatell.com'; $text = urlencode('This is an example message'); $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id"; $ret = file($url); $sess = split(":",$ret[0]); $sess_id = trim($sess[1]); if ($sess[0] == "OK") { $sql = mysql_query("SELECT * FROM calendar WHERE sendtxt = 1"); while ($row = mysql_fetch_array($sql)){ $text = urlencode('Hi '.$row['firstname'].' message here'); $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=".$row['cellphone']."&text=$text"; $ret = file($url); } if (!$ret) echo 'send message failed'; else echo 'success'; }else{ echo 'Authentication failure'; }
  21. Hi, Is the following a reasonable way to loop through database and send out sms, or are there better ways to go about it? $sql = mysql_query("SELECT * FROM calendar WHERE sendtxt = 1"); while ($row = mysql_fetch_array($sql)){ $user = '###'; $password = '###'; $api_id = '###'; $baseurl ="http://api.clickatell.com"; $text = urlencode("This is an example message"); $to = "".$row['cellphone'].""; $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id"; $ret = file($url); $sess = split(":",$ret[0]); if ($sess[0] == "OK") { $sess_id = trim($sess[1]); $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text"; $ret = file($url); $send = split(":",$ret[0]); if ($send[0] == "ID") echo "success<br>message ID: ". $send[1]; else echo "send message failed"; }else{ echo "Authentication failure: ". $ret[0]; } } Thanks
  22. Can it be done via php.ini rather than within the php script? Thanks
  23. Can it be changed in a php.ini file located in public_html dir? Thanks
×
×
  • 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.