Jump to content

searls03

Members
  • Posts

    907
  • Joined

  • Last visited

Everything posted by searls03

  1. I have noticed that sometimes there can be errors when copying and pasting code using the bbcode button, not all code will show when you click save....
  2. please look at the photo to see what I am replacing. I am trying to replace it with either a blank or a line break. <?php $needle='</tbody> </table> </td> <td> <table border="0" align="left"> <tbody>'; $content= str_replace ($needle, '<br> ', $content); echo $content; ?> anytime I try this though, nothing is happening(I am sure there is a good reason), but if I try a single line, it works fine....any help?
  3. <p>ok, I am not good at file uploads, I found most of file upload stuff from google....anyways, can anyone tell me why this wont upload the file to the two directories I am trying to? the first one does fine, the second one always shows the error. how can I make it upload to the two directories I want? <?php require_once "../Scripts/contentconnect.php"; if($_POST['submit']){ $target_path = "../images/"; $target_path = $target_path . basename( $_FILES['after']['name']); if(move_uploaded_file($_FILES['after']['tmp_name'], $target_path)) { echo "Please copy and paste this address to add an image: ../images/". basename( $_FILES['after']['name']). ""; $after=basename( $_FILES['after']['name']); } else{ echo "There was an error uploading the file, please try again!"; } } if($_POST['submit']){ $target_path1 = "../mobile/images/"; $target_path1 = $target_path1 . basename( $_FILES['after']['name']); if(move_uploaded_file($_FILES['after']['tmp_name'], $target_path1)) { } else{ echo "There was an error uploading the file, please try again!"; } } ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <p>Picture: <input type="file" name="after" id="after" /> </p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Save" onclick="" /> </p> </form>
  4. searls03

    $_Get

    is there anyway to keep the $_GET tag in the url stay permanently? as in www.example.com?id=1. then when I change the page, it stays, so www.example.com/page2.php?id=1? and if the id isn't there, then it wont show. but basically if it is there, it needs to stay there whereever i navigate to in the site, but if it isn't there, it won't show. I know I could use a session or cookie to do the same thing, but I am going to have it switch on and off, so it would be harder to undo, then reset it. please help me with my question, while not giving me different solutions than what I am looking for (ie. sessions).
  5. is there a way to use php, or some other coding, to make all pictures in a certain folder display as: <a href="directory here" title="title" target="_blank"><img src="source here" width="570" height="270" alt="Slide 2"></a> for example. so if there were two pictures, it would display them as: <a href="directory here" target="_blank"><img src="source here" width="570" height="270" alt="Slide 2"></a> <a href="directory2 here" target="_blank"><img src="source2 here" width="570" height="270" alt="Slide 3"></a> etc. I do not want to use a database with these please.
  6. How exactly do I incorporate with this piece of code? $month = date("F Y"); $day = date("d"); $year = date("Y"); $date = date("Y-m-d"); I am looking and can't quite figure it out....
  7. but how come a timestamp inserts correctly then....isn't that part of the server?
  8. why does everytime I use the php date function after 6 PM central time, it thinks it is the next day....I just use the day part of it, and it now thinks it is the 10 instead of 9
  9. ok, I do understand how to do multiple inserts, but I need it dynamically is the thing.
  10. As long as I don't have to change the tables or structures, I am willing to start the code again.
  11. well then how should I be running them? I thought that when you want to insert multiple things, you got to run a loop?
  12. maybe this is more correct? i am not for sure: if($_POST['submit']) { foreach ($_POST['city'] as $val) { $city = $val; if(isset($_POST['yes'])){ $orderable="yes"; }else{ $orderable=""; } $product = $_POST['product']; $product = str_replace("'","&#39;",$product); $product = str_replace('"',""",$product); $price1 = $_POST['price']; $price2 = $_POST['price2']; $price = "".$price1.".".$price2.""; $category = $_POST['category1']; $sub = $_POST['sub1']; $sql = "INSERT INTO products (category, subcategory, product, price, orderable, city) VALUES('$category', '$sub', '$product', '$price', '$orderable', '$city' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); $id1 = $_POST['id1']; $id12 = $_POST['id1']; $label = $_POST['label12345']; $sql = "INSERT INTO labels (`item_id`, `label`, `google`) VALUES ('$id12', '".$_POST['label12345']."', '".$_POST['label']."' )"; $rs = mysql_query($sql) or die ("Problem with the query: {$sql} <br />" . mysql_error()); echo $id45; $id45 = mysql_insert_id(); $users = $_POST['user']; foreach ($users as $key => $val) { $sql = "INSERT INTO options (`item_id`, `option`, label_id) VALUES ('{$id1}', '{$val}', '$id45' )"; $rs = mysql_query($sql) or die ("Problem with the query: {$sql} <br />" . mysql_error()); } $sql = "INSERT INTO products (category, subcategory, product, price, orderable, city) VALUES('$category', '$sub', '$product', '$price', '$orderable', '$city' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); } }
  13. it is also because items can have more than one label, by label, this is basically the type of option it is. so one could have a color/size.
  14. I am trying to keep it so that there arent blank columns and such, just makes it easier to organize for me. please help me with my code. hopefully this is a little bit better: if($_POST['submit']) { foreach ($_POST['city'] as $val) { $city = $val; if(isset($_POST['yes'])){ $orderable="yes"; }else{ $orderable=""; } $product = $_POST['product']; $product = str_replace("'","&#39;",$product); $product = str_replace('"',""",$product); $price1 = $_POST['price']; $price2 = $_POST['price2']; $price = "".$price1.".".$price2.""; $category = $_POST['category1']; $sub = $_POST['sub1']; $sql = "INSERT INTO products (category, subcategory, product, price, orderable, city) VALUES('$category', '$sub', '$product', '$price', '$orderable', '$city' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); $id1 = $_POST['id1']; $id12 = $_POST['id1']; $label = $_POST['label12345']; $sql = "INSERT INTO labels (`item_id`, `label`, `google`) VALUES ('$id12', '".$_POST['label12345']."', '".$_POST['label']."')"; $rs = mysql_query($sql) or die ("Problem with the query: {$sql} <br />" . mysql_error()); echo $id45; $id45 = mysql_insert_id(); $users = $_POST['user']; foreach ($users as $key => $val) { $sql = "INSERT INTO options (`item_id`, `option`, label_id) VALUES ('{$id1}', '{$val}', '$id45' )"; $rs = mysql_query($sql) or die ("Problem with the query: {$sql} <br />" . mysql_error()); } $sql = "INSERT INTO products (category, subcategory, product, price, orderable, city) VALUES('$category', '$sub', '$product', '$price', '$orderable', '$city' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); } } I never really do any indenting, I usually just search for what I want. sorry about this.
  15. can people not listen! I just said I do not want to change my code! There are like over 100 pages that rely on these tables. I know what I want to accomplish is possible, I just can't quite figure out the loops!
  16. The thing is, I already have code set up to work with these tables, because I previously had manually entered things. So changing the structure isn't really the best choice for this one.
  17. I don't know if this is possible, but what I am trying to do, is run a couple of queries for one form submission. This form creates products and ordering options for the products and which cities they can be sold in. 1st, I run a foreach loop to insert the products into the table, lets say I selected three cities, so it would insert 3 times with appropriate city names. this table would look like this: id, product, category, subcategory, price, orderable, city. so there would be three entries for the "test" product looking like this: id | Product | Category | Subcategory | price | orderable | City ----------------------------------------------------------------------------------------------- 1 | test1 | test | none | 10.00 | no | Las Vegas ----------------------------------------------------------------------------------------------- 2 | Test | test | none | 10.00 | yes | San Fran ----------------------------------------------------------------------------------------------- 3 | Test | test | none | 10.00 | yes | Miami ----------------------------------------------------------------------------------------------- 4 | Test | test | none | 10.00 | yes | New York ----------------------------------------------------------------------------------------------- Then foreach time it inserts a city, it will insert into another table called labels that has the structure of: id, label, item_id, google the table would look like this when completed id | label | item_id | google --------------------------------------------- 1 | Test | 2 | Test --------------------------------------------- 2 | Test | 3 | Test --------------------------------------------- 3 | Test | 4 | Test --------------------------------------------- The only reason I included the test1 product in the first table was to show that the id will not always match the item_id in the labels table. Now there are multiple options for each product that can be used in the table options: id, item_id, option, label_id. id | item_id | option | label_id --------------------------------------------- 1 | 2 | Red | 1 --------------------------------------------- 2 | 2 | Blue | 1 --------------------------------------------- 3 | 2 | Green | 1 --------------------------------------------- 4 | 3 | Red | 2 --------------------------------------------- 5 | 3 | Blue | 2 --------------------------------------------- 6 | 3 | Green | 2 --------------------------------------------- 7 | 4 | Red | 3 --------------------------------------------- 8 | 4 | Blue | 3 --------------------------------------------- 9 | 4 | Green | 3 --------------------------------------------- so what it is basically doing if foreach city, it will insert the product, so in this case, it was 4 cities so 4 times. Then it inserted labels for all products that were marked as orderable, so there were 1 orderable in 3 cities, so it inserted it 3 times into labels. then for each label and each product/city, they had 3 options, red, blue, green. So foreach label, so id of 1, it inserted 3 options into my options table with ids 1,2,3. it did this for each label then. does this kinda make sense as to what I would like it to do? I need some starts with the code for this. this is what I have so far: foreach ($_POST['city'] as $val) { $city = $val; if(isset($_POST['yes'])){ $orderable="yes";}else{$orderable="";}$product = $_POST['product']; $product = str_replace("'","&#39;",$product); $product = str_replace('"',""",$product); $price1 = $_POST['price']; $price2 = $_POST['price2']; $price = "".$price1.".".$price2.""; $category = $_POST['category1']; $sub = $_POST['sub1']; $sql = "INSERT INTO products (category, subcategory, product, price, orderable, city) VALUES('$category', '$sub', '$product', '$price', '$orderable', '$city' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); $id1 = $_POST['id1']; $id12 = $_POST['id1']; $label = $_POST['label12345']; $sql = "INSERT INTO labels (`item_id`, `label`, `google`) VALUES ('$id12', '".$_POST['label12345']."', '".$_POST['label']."' )"; $rs = mysql_query($sql) or die ("Problem with the query: {$sql} <br />" . mysql_error()); echo $id45; $id45 = mysql_insert_id(); $users = $_POST['user']; foreach ($users as $key => $val) { $sql = "INSERT INTO options (`item_id`, `option`, label_id) VALUES ('{$id1}', '{$val}', '$id45' )"; $rs = mysql_query($sql) or die ("Problem with the query: {$sql} <br />" . mysql_error()); } $sql = "INSERT INTO products (category, subcategory, product, price, orderable, city) VALUES('$category', '$sub', '$product', '$price', '$orderable', '$city' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); } }
  18. ok I am using this: <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script> <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $("#form1").validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('graph.php', $("#form1").serialize(), function(data) { $("#apDiv3").load("graph.php #apDiv3"); $("#apDiv8").load("graph.php #apDiv8"); }); } }); }); </script> and this: <form id="form1" method="post"> <select name="academy" onchange="this.form.submit()"> <option value="Old_Cheney">Old Cheney</option> <option value="Yankee_HIll">Yankee Hill</option> <option value="Holdrege">Holdrege</option> <option value="Center">Center</option> <option value="Maple">Maple</option> </select> </form> and this is the divs it should load: <div id="apDiv3"> <p> <script type="text/javascript"> // BeginOAWidget_Instance_2281525: #jQueryVisualizeChart $(function(){ $('#table').visualize({type: 'line', height: '300px', width: '420px', appendTitle : true, lineWeight : 4, colors : ['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744']}).appendTo('#jQueryVisualizeChart').trigger('visualizeRefresh'); }); // EndOAWidget_Instance_2281525 </script> <div id="jQueryVisualizeChart"></div> <script type="text/javascript"> // BeginOAWidget_Instance_2281525: #jQueryVisualizeChart_2 $(function(){ $('#table').visualize({type: 'bar', height: '300px', width: '420px', appendTitle : true, lineWeight : 4, colors : ['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744']}).appendTo('#jQueryVisualizeChart_2').trigger('visualizeRefresh'); }); // EndOAWidget_Instance_2281525 </script> <br /> <table id="table" style="display:none"> <caption> </caption> <thead> <tr> <td></td> <th scope="col"><?php $date1= date("F Y", strtotime("-5 months")); echo $date1 ?></th> <th scope="col"><?php $date2= date("F Y", strtotime("-4 months")); echo $date2 ?></th> <th scope="col"><?php $date3= date("F Y", strtotime("-3 months")); echo $date3 ?></th> <th scope="col"><?php $date4= date("F Y", strtotime("-2 months")); echo $date4 ?></th> <th scope="col"><?php $date5= date("F Y", strtotime("-1 months")); echo $date5 ?></th> <th scope="col"><?php $date6= date("F Y", strtotime("-0 months")); echo $date6 ?></th> </tr> </thead> <tbody> <th scope="row">Old Cheney</th> <td> <?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date1."'"); while($row = mysql_fetch_array($sql)){ $price = $row["price"]; echo $price;} ?></td> <td><?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date2."'"); while($row = mysql_fetch_array($sql)){ $price2 = $row["price"]; echo $price2;} ?></td> <td><?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date3."'"); while($row = mysql_fetch_array($sql)){ $price3 = $row["price"]; echo $price3;} ?></td> <td><?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date4."'"); while($row = mysql_fetch_array($sql)){ $price4 = $row["price"]; echo $price4;} ?></td><td><?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date5."'"); while($row = mysql_fetch_array($sql)){ $price5 = $row["price"]; echo $price5;} ?></td> <td><?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date6."'"); while($row = mysql_fetch_array($sql)){ $price6 = $row["price"]; echo $price6;} ?></td> </tr> </table> <p><br /> </p> </div> <div id="apDiv8"><div id="jQueryVisualizeChart_2"></div></div> yet, the page is still refreshing...does anyone see why?
  19. Thank you, that is what I was thinking...
  20. ok, so here is what I have so far <?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '$_POST['academy']' AND month='".$date1."'"); while($row = mysql_fetch_array($sql)){ $price = $row["price"]; echo $price;} ?> I would like to use a drop down menu that when selected, it would change the $_POST['academy'] to the selected value of the dropdown. I don't want the page to refresh either. how could I do this?
  21. But what would be a way I could "paginate" the dates. I have a forward 6 months and a backwards 6 months buttons and I would like the dates at the top of the graph to reflect that when I click on them. Any help with that?
  22. ok so I am working on a graphing system with titles of <th scope="col"><?php echo date("F Y", strtotime("-5 months")); ?></th> <th scope="col"><?php echo date("F Y", strtotime("-4 months")); ?></th> <th scope="col"><?php echo date("F Y", strtotime("-3 months")); ?></th> <th scope="col"><?php echo date("F Y", strtotime("-2 months")); ?></th> <th scope="col"><?php echo date("F Y", strtotime("-1 months")); ?></th> <th scope="col"><?php echo date("F Y"); ?></th> what I would like to know is how I could use some buttons or forms to make it so that there are 6 months forward, and 6 months backwards everytime I click on one of the two buttons. any help?
  23. ok, thanks, do you have any advice?
  24. I am saying that I would like to use PHP to query the database, I don't want to do it from PHPmyAdmin/Mysql. so a query like this: // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM cart where cart_id = '".$_SESSION['cart_id']."' && academy= '$academy' && product123 !=''"); while($row = mysql_fetch_array($sql)){ $product = $row["product123"]; $price1 = $row["price"]; $id = $row["product_id"]; $qty = $row["quantity"];
  25. I would like to do this using a PHP query, not a mysql sql query
×
×
  • 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.