Jump to content

searls03

Members
  • Posts

    907
  • Joined

  • Last visited

Everything posted by searls03

  1. so there is no way to do an if isset type of thing, then a message appears? do you have any suggestions?
  2. Ok, so what is happening is my form submits to this: <body> <?php // load Zend Gdata libraries require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // set credentials for ClientLogin authentication $user = "user"; $pass = "password"; try { // connect to API $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $service = new Zend_Gdata_Spreadsheets($client); // set target spreadsheet and worksheet $ssKey = 'ssKey'; $wsKey = 'wsKey'; $name='Aaron Searls'; $item= "".$_POST['item']."".$_POST['item1'].""; // create row content $row = array( "date" => date('m-d-y'), "name" => $name, "item" => $item, "paid" => 'yes' ); // insert new row $entryResult = $service->insertRow($row, $ssKey, $wsKey); } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } echo $name; echo $item; ?> <?php echo 'aaron'; echo $item; ?> </body> <html> This is the form: <form method="POST" name="myform<?php echo $id; ?>" id="myform<?php echo $id; ?>"> <?php if ((strpos($val,'Sparring') || strpos($val,'Feet')) !== false){ ?> <input name="item" type="hidden" value="Sparring Feet Size: " /> <select name="item1"> <option idue="Child 12/13">Child 12/13</option> <option value="1/2">1/2</option> <option value="3/4">3/4</option> <option value="5/6">5/6</option> <option value="7/8">7/8</option> <option value="9/10">9/10</option> <option value="11/12">11/12</option> <option value="13/14">13/14</option> </select> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Hands')) !== false){ ?> <input name="item" type="hidden" value="Sparring Hands...shoe size: " /> please enter shoe size(hands are based on shoe size) <input name="item1" type="text" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Shins')) !== false){ ?> <input name="item" type="hidden" value="Sparring shins...shoe size:" /> please enter shoe size(shins are based on shoe size) <input name="item1" type="text" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'head')) !== false){ ?> <input name="item" type="hidden" value="Sparring Head: size" /> please keep in mind most people are XL <select name="item1"> <option value="Small">Small</option> <option value="Medium">Medium/Lg</option> <option value="Large">X-Large</option> </select> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Elbow Pads')) !== false){ ?> <input name="item" type="hidden" value="elbow pads" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Groin Protector')) !== false){ ?> <input name="item" type="hidden" value="Groin protector size: " /> <select name="item1"> <option value='Child Cup Sm (20"-26")'>Child Cup Sm (20"-26")</option> <option value='Child Cup Lrg (26"-32")'>Child Cup Lrg (26"-32")</option> <option value='Adult Small (26"-32")'>Adult Small (26"-32")</option> <option value='Adult Medium (32"-38")'>Adult Medium (32"-38")</option> <option value='Adult Large (38"-44")'>Adult Large (38"-44")</option> <option value='Adult X-Large (44"-50")'>Adult X-Large (44"-50")</option> </select> <?php } else if ($val=='Sparring/Ecas Gear:ECAS Gear'){ ?> <input name="item" type="hidden" value="Ecas Gear size " /> Shin/elbow <select name="shin/elbow"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option> <option value="X-Large">X-Large</option> </select> Shin/elbow <select name="glove"> <option value="Sm/Med">Sm/Med</option> <option value="Lg/Xl">Lg/Xl</option> </select> <?php } ?> <input type="submit" name="hellobob" value="Submit" /> </form> The code submits to ajax without a page refresh. After it submits to the ajax which submits to the first code, I want the submit button and the form field to turn into a message saying submitted. How do I do this? does this make sense?
  3. Im sorry, I just use a link from my email to get to the forum, then i post in the forum that is just there.....I always forget about the other ones
  4. I am pretty sure the problem I am running into here is within my loop. But why does the form not submit to the ajax, but it keeps trying to submit to itself? it is supposed to do ajax... <?php foreach($_POST["product"] AS $key => $val) { $product = $val;?> <script type="text/javascript"><!-- if(document.all && !document.getElementById) { //IE4 support document.getElementById = function(id) { return document.all[id]; } } function dss_addLoadEvent(fn) { if(typeof(fn)!="function")return; var tempFunc=window.onload; window.onload=function() { if(typeof(tempFunc)=="function")tempFunc(); fn(); } } dss_addLoadEvent(function() { if(!document.getElementById) return; var f = document.getElementById('form<?php echo $val; ?>'); // to prevent the form from submitting in this demo f.onsubmit = function(){ return false; } // hide the textarea and its parent label document.getElementById('demo_radio_ta_label<?php echo $val; ?>').style.display = 'none'; // get a reference to the radio button group var rads = f.elements['demo_radio<?php echo $val; ?>']; for(var i=0;i<rads.length;i++) { // we add the event handler to each button in the group rads[i].onkeyup=rads[i].onclick=function(){ if(!this.checked) return; var el = document.getElementById('demo_radio_ta_label<?php echo $val; ?>'); el.style.display = (this.value=="yes")?'':'none'; } // in case, for any reason, one of the radio buttons is already checked rads[i].onclick(); } }); // --> </script> <form id="form<?php echo $val;?>" name="form<?php echo $val; ?>" method="POST"> Does <?php echo $val; ?> need to be ordered? <br /> <label for="rad1"> <input type="radio" name="demo_radio<?php echo $val;?>" id="rad1<?php echo $val; ?>" value="yes">Yes</label> <br/> <label for="rad2"><input type="radio" name='demo_radio<?php echo $val; ?>' id='rad2<?php echo $val; ?>' value='no'> No</label> </form> <div class='label<?php echo $val; ?>' id='demo_radio_ta_label<?php echo $val; ?>'> <script> $(document).ready(function(){ $(".myform<?php echo $val; ?>").validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('insert.php', $(".myform<?php echo $val; ?>").serialize(), function(data) { }); } }); }); </script><form method="POST" name="myform<?php echo $val; ?>" class="myform<?php echo $val; ?>"> <?php if ((strpos($val,'Sparring') || strpos($val,'Feet')) !== false){ ?> <input name="item" type="hidden" value="Sparring Feet Size: " /> <select name="item1"> <option value="Child 12/13">Child 12/13</option> <option value="1/2">1/2</option> <option value="3/4">3/4</option> <option value="5/6">5/6</option> <option value="7/8">7/8</option> <option value="9/10">9/10</option> <option value="11/12">11/12</option> <option value="13/14">13/14</option> </select> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Hands')) !== false){ ?> <input name="item" type="hidden" value="Sparring Hands...shoe size: " /> please enter shoe size(hands are based on shoe size) <input name="item1" type="text" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Shins')) !== false){ ?> <input name="item" type="hidden" value="Sparring shins...shoe size:" /> please enter shoe size(shins are based on shoe size) <input name="item1" type="text" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'head')) !== false){ ?> <input name="item" type="hidden" value="Sparring Head: size" /> please keep in mind most people are XL <select name="item1"> <option value="Small">Small</option> <option value="Medium">Medium/Lg</option> <option value="Large">X-Large</option> </select> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Elbow Pads')) !== false){ ?> <input name="item" type="hidden" value="elbow pads" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Groin Protector')) !== false){ ?> <input name="item" type="hidden" value="Groin protector size: " /> <select name="item1"> <option value='Child Cup Sm (20"-26")'>Child Cup Sm (20"-26")</option> <option value='Child Cup Lrg (26"-32")'>Child Cup Lrg (26"-32")</option> <option value='Adult Small (26"-32")'>Adult Small (26"-32")</option> <option value='Adult Medium (32"-38")'>Adult Medium (32"-38")</option> <option value='Adult Large (38"-44")'>Adult Large (38"-44")</option> <option value='Adult X-Large (44"-50")'>Adult X-Large (44"-50")</option> </select> <?php } else if ($val=='Sparring/Ecas Gear:ECAS Gear'){ ?> <input name="item" type="hidden" value="Ecas Gear size " /> Shin/elbow <select name="shin/elbow"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option> <option value="X-Large">X-Large</option> </select> Shin/elbow <select name="glove"> <option value="Sm/Med">Sm/Med</option> <option value="Lg/Xl">Lg/Xl</option> </select> <?php } ?> <input type="submit" name="hellobob" value="Submit" /> </form> </div> <?php } ?> Can anyone help? It is the second form by the way
  5. searls03

    syntax

    sorry, I got it figured out. I will mark as solved.
  6. searls03

    syntax

    it has something to do with the fieldset............it is thinking it is outside of a form, even though it is inside the form. how do I fix this? <?php foreach($_POST["product"] AS $key => $val) { $product = $val;?> <form id="form1<?php echo $val;?>" action="#"> <fieldset><legend>Does <?php echo $val; ?> need to be ordered?</legend> <legend> <label for="rad1"> <input type="radio" name="demo_radio<?php echo $val;?>" id="rad1<?php echo $val; ?>" value="yes">Yes</label> <br/> <label for="rad2"><input type="radio" name='demo_radio<?php echo $val; ?>' id='rad2<?php echo $val; ?>' value='no'> No</label> <div class='label' id='demo_radio_ta_label<?php echo $val; ?>'> <?php if ((strpos($val,'Sparring') || strpos($val,'Feet')) !== false){ ?> <form action="insert.php" method="post" enctype="multipart/form-data" > <select name="item1"> <option value="Child 12/13">Child 12/13</option> <option value="1/2">1/2</option> <option value="3/4">3/4</option> <option value="5/6">5/6</option> <option value="7/8">7/8</option> <option value="9/10">9/10</option> <option value="11/12">11/12</option> <option value="13/14">13/14</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Hands')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Sparring Hands...shoe size: " /> please enter shoe size(hands are based on shoe size) <input name="item1" type="text" /> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Shins')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Sparring shins...shoe size:" /> please enter shoe size(shins are based on shoe size) <input name="item1" type="text" /> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'head')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Sparring Head: size" /> please keep in mind most people are XL <select name="item1"> <option value="Small">Small</option> <option value="Medium">Medium/Lg</option> <option value="Large">X-Large</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Elbow Pads')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="elbow pads" /> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Groin Protector')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Groin protector size: " /> <select name="item1"> <option value='Child Cup Sm (20"-26")'>Child Cup Sm (20"-26")</option> <option value='Child Cup Lrg (26"-32")'>Child Cup Lrg (26"-32")</option> <option value='Adult Small (26"-32")'>Adult Small (26"-32")</option> <option value='Adult Medium (32"-38")'>Adult Medium (32"-38")</option> <option value='Adult Large (38"-44")'>Adult Large (38"-44")</option> <option value='Adult X-Large (44"-50")'>Adult X-Large (44"-50")</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ($val=='Sparring/Ecas Gear:ECAS Gear'){ ?> <form action="" method="post" class="sub"><input name="item" type="hidden" value="Ecas Gear size " /> Shin/elbow <select name="shin/elbow"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option> <option value="X-Large">X-Large</option> </select> Shin/elbow <select name="glove"> <option value="Sm/Med">Sm/Med</option> <option value="Lg/Xl">Lg/Xl</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } ?> </div></legend></fieldset></form> <?php } ?>
  7. searls03

    syntax

    ok, well what do you see? I figured it was syntax, but I guess not. I seem to have a problem with the fieldset and the div
  8. searls03

    syntax

    somewhere in here is some syntax error....can you help me find it? I cant seem to find it: <?php } ?> <?php foreach($_POST["product"] AS $key => $val) { $product = $val;?> <form id="form1" action="#"> <fieldset class="radio"> <legend>Does <?php echo $val; ?> need to be ordered?</legend> <legend> <label for="rad1"><input type="radio" name="demo_radio<?php echo $val; ?>" id="rad1<?php echo $val; ?>" value="yes" > Yes</label><br> <label for="rad2"><input type="radio" name="demo_radio<?php echo $val; ?>" id="rad2<?php echo $val; ?>" value="no" > No</label> <div class="label" id="demo_radio_ta_label<?php echo $val; ?>"> <?php if ((strpos($val,'Sparring') || strpos($val,'Feet')) !== false){ ?> <form action="" method="post" class="sub"><input name="item" type="hidden" value="Sparring Feet: size" /> <select name="item1"> <option value="Child 12/13">Child 12/13</option> <option value="1/2">1/2</option> <option value="3/4">3/4</option> <option value="5/6">5/6</option> <option value="7/8">7/8</option> <option value="9/10">9/10</option> <option value="11/12">11/12</option> <option value="13/14">13/14</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Hands')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item1" type="hidden" value="Sparring Hands...shoe size: " /> please enter shoe size(hands are based on shoe size) <input name="hands" type="text" /> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Shins')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Sparring shins...shoe size:" /> please enter shoe size(shins are based on shoe size) <input name="item1" type="text" /> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'head')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Sparring Head: size" /> please keep in mind most people are XL <select name="item1"> <option value="Small">Small</option> <option value="Medium">Medium/Lg</option> <option value="Large">X-Large</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Elbow Pads')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="elbow pads" /> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Groin Protector')) !== false){ ?> <form action="" method="post" class="sub"> <input name="item" type="hidden" value="Groin protector size: " /> <select name="item1"> <option value='Child Cup Sm (20"-26")'>Child Cup Sm (20"-26")</option> <option value='Child Cup Lrg (26"-32")'>Child Cup Lrg (26"-32")</option> <option value='Adult Small (26"-32")'>Adult Small (26"-32")</option> <option value='Adult Medium (32"-38")'>Adult Medium (32"-38")</option> <option value='Adult Large (38"-44")'>Adult Large (38"-44")</option> <option value='Adult X-Large (44"-50")'>Adult X-Large (44"-50")</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } else if ((strpos($val,'ECAS') || strpos($val,'Gear')) !== false){ ?> <form action="" method="post" class="sub"><input name="item" type="hidden" value="Ecas Gear size " /> Shin/elbow <select name="shin/elbow"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option> <option value="X-Large">X-Large</option> </select> Shin/elbow <select name="glove"> <option value="Sm/Med">Sm/Med</option> <option value="Lg/Xl">Lg/Xl</option> </select> <input name="submit" type="submit" value="submit" /> </form> <?php } ?> </div> </legend> </fieldset> </form> <?php } ?>
  9. I did read the manual and I couldn't find what I wanted.
  10. How do I do two strpos conditions? here is kinda what I have.... if (strpos($val,'Sparring') && ($val,'Ecas') { }
  11. searls03

    Zend

    I am using Zend Gdata to insert rows into a google spread sheet. how do I modify the insert code to insert multiple entries at the same time? I am pretty sure I need a foreach loop, can somebody help me write it? // create row content $row = array( "date" => date('m-d-y'), "name" => $_POST['name'], "item" => $_POST['item'], "paid" => $_POST['paid'] ); // insert new row $entryResult = $service->insertRow($row, $ssKey, $wsKey); echo 'The ID of the new row entry is: ' . $entryResult->id; } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?>
  12. How do I download a table that php queried to excel? I have a code that downloads a table, but how would I make it so that the query for the table is the same as the query for the html table? here is the excel: $select = "SELECT academy, product FROM transactions"; $export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) ); $fields = mysql_num_fields ( $export ); for ( $i = 0; $i < $fields; $i++ ) { $header .= mysql_field_name( $export , $i ) . "\t"; } while( $row = mysql_fetch_row( $export ) ) { $line = ''; foreach( $row as $value ) { if ( ( !isset( $value ) ) || ( $value == "" ) ) { $value = "\t"; } else { $value = str_replace( '"' , '""' , $value ); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim( $line ) . "\n"; } $data = str_replace( "\r" , "" , $data ); if ( $data == "" ) { $data = "\n(0) Records Found!\n"; } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=your_desired_name.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; here is the html: <?php session_start(); require_once "connect.php"; if(isset($_SESSION['logged'])){ $cid = $_SESSION['complete']; $academy = $_SESSION['academy']; } echo $cid; echo $academy; ?> <style type="text/css"> body p { font-size: 14px; } body p { font-size: 24px; } #0 tr td { font-size: 24px; } #0 { font-size: 24px; } </style> <br /> </p> <table width="1200" border="1" cellpadding="0" cellspacing="0" id="0"> <tr style="background-color: #999; font-size: 16px;"> <th width="132" scope="col">Academy</th> <th width="401" scope="col">Product</th> <th width="139" scope="col">Qty.</th> <th width="194" scope="col">Net Price</th> <th width="164" scope="col">Price per unit</th> <th width="259" scope="col">Date Sold</th> </tr> <?php if($_POST['submit']) { $startdate=$_POST['startdate']; $enddate=$_POST['enddate']; $category1=$_POST['category']; $academy1=$_POST['academy']; $products1=$_POST['products']; echo $academy1; if($category1 =="----All----"){ $category1 ='';} else {$category1 = "&& category='".$_POST['category']."'";} if($academy1 =="----All----"){ $academy1 = ''; } else{$academy1 = "and Academy='".$academy1."'"; } if($products1 == "----All----"){ $products1 = ''; } else{$products1 = "and product='".$_POST['products']."'"; } $result = mysql_query("SELECT * FROM transactions where date between '$startdate' and '$enddate' $category1 $products1 $academy1"); $_SESSION['query']= $result; $_SESSION['category1']= $category1; $_SESSION['academy1']= $academy1; $_SESSION['products1']= $products1; while($row = mysql_fetch_array($result)) { $date = $row["date"]; $product = $row["product"]; $month = $row["month"]; $day = $row["day"]; $year = $row["year"]; $category = $row["category"]; $academy = $row["Academy"]; $price = $row["price"]; $priceunit = $row["priceunit"]; $quantity = $row["quantity"]; echo "<tr id='0'>"; echo "<td>"; echo $academy; echo "</td>"; echo "<td>"; echo $product; echo "</td>"; echo "<td>"; echo $quantity; echo "</td>"; echo "<td>"; setlocale(LC_MONETARY, "en_US"); echo money_format("%n", $price); echo "</td>"; echo "<td>"; setlocale(LC_MONETARY, "en_US"); echo money_format("%n", $priceunit); echo "</td>"; echo "<td>"; echo $date; echo "</td>"; echo "</tr>"; $total = $price + $total; } } ?> <tr> <td scope="col">Totals:</td> <th scope="col"> </th> <th scope="col"> </th> <th scope="col"><?php setlocale(LC_MONETARY, "en_US"); echo money_format("%n", $total); ?></th> <th scope="col"> </th> <th scope="col"> </th> </tr> </table><a href="print.php" > export to excel</a>
  13. how do I modify the date coming from the database in YYYY-MM-DD format to MM-DD-YYYY?
  14. I am pretty sure the sessions aren't setting.....when I go to index.php and try to echo them out, nothing shows....
  15. ok so here is the code: <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check include_once "connect.php"; // Place Session variable 'id' into local variable $sql = mysql_query("SELECT * FROM cart"); while($row = mysql_fetch_array($sql)){ $cid = $row["cart_id"]; $academy = $row["academy"]; $complete = "".$cid."".$academy.""; $_SESSION['complete'] = $complete; $_SESSION['cart_id'] = $cid; $_SESSION['academy'] = $academy; } if (!isset($_SESSION['complete'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect.php"; // Place Session variable 'id' into local variable $academy = $_SESSION['academy']; $sql = mysql_query("SELECT * FROM cart"); while($row = mysql_fetch_array($sql)){ $cid = $row["cart_id"]; $_SESSION['cart_id'] = $cid; } echo $cid; echo "<br />"; echo $academy; ?> what I need to know how to do is arrange my code so that if the person is logged in already, the part before the if isnot set, will run. but if the person is not already logged in, they must login first. the problem is if one person is logged in, all people can get logged in. please help.... I may not be setting them right either. : <?php /* Created By Adam Khoury @ [url=http://'http://www.flashbuilding.com/']www.flashbuilding.com[/url] -----------------------June 20, 2008----------------------- */ if ($_POST['username']) { //Connect to the database through our include include_once "connect.php"; $username = stripslashes($_POST['username']); $username = strip_tags($username); $username = mysql_real_escape_string($username); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); $password = md5($password); // filter everything but numbers and letters // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Get member ID into a session variable $academy = $row["academy"]; $_SESSION['academy'] = $academy; $_SESSION['logged'] = "1"; function genRandomString($length = 20) { $characters = '0123456789'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } $bar = genRandomString(); $sql = "INSERT INTO cart (cart_id, academy) VALUES('".$bar."".$academy."','$academy' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); $id = $bar; $_SESSION['cart_id'] = $cid; $_SESSION['complete'] = "".$cid."".$academy.""; // Get member username into a session variable $errorMsg = ''; $pass = ''; $remember = ''; if (isset($_POST['Submit'])) { $pass = $_POST['password']; if (isset($_POST['remember'])) { $remember = $_POST['remember']; } $pass = stripslashes($pass); $pass = strip_tags($pass); if($remember == "yes"){ $encryptedID = base64_encode("g4enm2c0c4y3dn3727553$id"); setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days setcookie("passCookie", $password, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days } // All good they are logged in, send them to homepage then exit script header("location: index.php"); exit(); }} // close while } else { // Print login failure message to the user and link them back to your login page print '<br /><br /><font color="#FF0000">Sorry, incorrect username or password, please try again! </font><br />'; }} ?> It seems that I have to query the database on every page for them to actually work...why is this? I don't beleive they are setting....like I echo logged, but nothing shows......so I don't think they are working.
  16. scootsah, where exactly in my code would this go?
  17. that should be a select box....not a drop down menu
  18. Has anyone out there seen a search menu that is a drop down menu? ie. it is a drop down menu, but at the top it is a search box that will gradually limit the results in the drop down? it will search all content in the drop down. has anybody seen anything like this? basically it eliminates results as you type.
  19. one last thing, how would I make this display in rows instead of columns? <?php $x = 1; // set $x for ($i=1; $i<=100; $i += 9) { $start[] = $i; } //columns will be started at each of these numbers for ($i=9; $i<=100; $i += 9) { $end[] = $i; } //columns wilecho $end; echo '<table><tr>'; //start the table, and the row. // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM products where category='retail' and subcategory='none'"); while($row = mysql_fetch_array($sql)){ $product = $row["product"]; $id =$row["id"]; $price =$row["price"]; if (in_array($x, $start)) { // if x equals a number in the start array echo '<td>'; // start a column } ?> <div id="products"> <form action="" method="POST" name="myform<?php echo $id; ?>" class="myform<?php echo $id; ?>"> <input type="hidden" name="hiddenField" class="hiddenField" value="<?php echo $product; ?>" /> <input type="hidden" name="hiddenField2" class="hiddenField2" value="<?php echo $id; ?>" /> <input type="hidden" name="hiddenField1" class="hiddenField1" value="<?php echo $price; ?>" /> <input type="submit" name="submit" class="submit" value="<?php echo $product; ?>" style="background-color:lightgreen; height:50px; width:100px;"> </form> </div> <?php if (!in_array($x, $end)){ // if $x equals anything OTHER than 9, 18, etc - put in a line break } else { // else if it DOES equal 9, 18 ,etc end the column echo '</td>'; } $x ++; // increase x to keep count } // while loop ends //now outside of the loop, $x = $x - 1; //subtract the last $X++ so you know exactly how many buttons were added if (!in_array($x, $end)){ // if $x equals anything OTHER than 9, 18, etc - end the column as it wouldn't have ended itself echo '</td>'; } echo '</tr></table>'; // close the row and table ?>
  20. here is what I am trying to do....I am making columns of buttons, I need the buttons to automatically increment for me. This is what i have <?php $x = 1; // set $x for ($i=1; $i<=100; $i += 9) { $count[] = "'{$i}'";} $start1 = implode(', ',$count); // set layout vars $x = 1; // set $x $start = array (implode(', ', $count)); //columns will be started at each of these numbers $end = array( '9', '18' ); // set numbers to end columns at echo $end; echo '<table><tr>'; //start the table, and the row. // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM products where category='retail' and subcategory='none'"); while($row = mysql_fetch_array($sql)){ $product = $row["product"]; $id =$row["id"]; $price =$row["price"]; if (in_array($x, $start)) { // if x equals a number in the start array echo '<td>'; // start a column } ?> this is what I am trying to make using that code that makes numbers <?php $x = 1; // set $x for ($i=1; $i<=100; $i += 9) { $count[] = "'{$i}'";} $start1 = implode(', ',$count); // set layout vars $x = 1; // set $x $start = array ('1', '10', '19', etc); //columns will be started at each of these numbers $end = array( '9', '18' ); // set numbers to end columns at echo $end; echo '<table><tr>'; //start the table, and the row. // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM products where category='retail' and subcategory='none'"); while($row = mysql_fetch_array($sql)){ $product = $row["product"]; $id =$row["id"]; $price =$row["price"]; if (in_array($x, $start)) { // if x equals a number in the start array echo '<td>'; // start a column } ?> The code that i tried for dynamic(first code) does not work. how do I make it so that it duplicates what is in the second code?
  21. ok....the value that it echoing I would like to put into the place in the code where it says $stick in here
  22. how do I use this code....only instead of making columns, they make rows?
  23. and how would I stick it into this code: $x = 1; // set $x for ($i=1; $i<=100; $i += 9) { $count[] = "'{$i}'";} echo implode(', ',$count); // set layout vars $start = array ($stick in here); //columns will be started at each of these numbers where I want it to go inside where it says $stick in here?
  24. how do I use this code and not add a "," after the last $i? $x = 1; // set $x for ($i=1; $i<=100; $i += 9) { echo "'".$i."',";} you may change how you want.....I am pretty sure it needs a counter... but I don't know much about them
  25. So I have this: <?php include_once("connect.php"); session_start(); if($_POST['pay']){ foreach($_POST["product"] AS $key => $val) { $product = $val; $month = $_POST['month'][$key]; $day = $_POST['day'][$key]; $year = $_POST['year'][$key]; $date = $_POST['date'][$key]; $price = $_POST['price'][$key]; $qty = $_POST['qty'][$key]; $id = $_POST['id'][$key]; $total = $_POST['total'][$key]; $academy = $_POST['academy'][$key]; $priceunit = $price * $qty; } if($_POST['submit']){ $sql = "INSERT INTO transactions (date, month, day, year, product, product_id, category, academy, price, quantity, priceunit) VALUES('$date', '$month', '$day', '$year', '$product', '$id', '$category', '$academy', '$price', '$qty', '$priceunit' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); }} ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif; background: #42413C; margin: 0; padding: 0; color: #000; } /* ~~ Element/tag selectors ~~ */ ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */ padding: 0; margin: 0; } h1, h2, h3, h4, h5, h6, p { margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */ padding-right: 15px; padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */ } a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */ border: none; } /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */ a:link { color: #42413C; text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */ } a:visited { color: #6E6C64; text-decoration: underline; } a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */ text-decoration: none; } /* ~~ this fixed width container surrounds the other divs ~~ */ .container { width: 960px; background: #FFF; margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */ } /* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */ .header { background: #ADB96E; } /* ~~ This is the layout information. ~~ 1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. */ .content { padding: 10px 0; } /* ~~ The footer ~~ */ .footer { padding: 10px 0; background: #CCC49F; } /* ~~ miscellaneous float/clear classes ~~ */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */ float: left; margin-right: 8px; } .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */ clear:both; height:0; font-size: 1px; line-height: 0px; } --> </style></head> <body> <div class="container"> <div class="header"><a href="#"><img src="" alt="Insert Logo Here" name="Insert_logo" width="180" height="90" id="Insert_logo" style="background: #C6D580; display:block;" /></a> <!-- end .header --></div> <div class="content"> <form id="form1" name="form1" method="post" action="collect.php"> <input type="text" name="payment" id="payment" /><input name="submit" type="submit" value="Checkout" /> </form> <h1> </h1> <!-- end .content --></div> <div class="footer"> <p>Footer</p> <!-- end .footer --></div> <!-- end .container --></div> </body> </html> my goal is that the arrays that are set at the beginning of the page (pay comes from another page) will hold themselves until submit is posted that way nothing will insert until a sale is confirmed with the amount somebody payed. so basically I need to know how to hold those arrays so that they can be used to insert later
×
×
  • 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.