Jump to content

denoteone

Members
  • Posts

    383
  • Joined

  • Last visited

    Never

Everything posted by denoteone

  1. @RussellReal but I want to do it so that if there is a long name there will not be any issues. @The Little Guy I will try this method and let you know what i come up with.
  2. This would fall under PHP and MySQL. I need to get names out of a database and echo them into a list. I am trying to break the list into two columns Below is what I normally use. <?PHP $query = "SELECT name, FROM contact WHERE location = ohio"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_NUM)) { ?><li><?PHP echo $row[0]; ?></li> } The above code should print the list in a straight line. Below I have started what I think needs to be done to split it into two columns. Any help solving this would be great. $total = total number of $row[]; $half = $total / .5; for (i = 0; i < $total; i ++){ if(i < $half){ ?> <li><?PHP echo $row[i]; ?> </li> <?PHP else { ?> <li><?PHP echo $row[i]; ?> </li> <?PHP
  3. That's exactly what I want to do. Thanks for your help you saved me a ton of tedious work!
  4. I like Crayon Violent but.... would I use <input type="text" name="price[leg_s]" > <input type="text" name="price[leg_m]" > <input type="text" name="price[leg_1]" > <input type="text" name="price[leg_x1]" > instead of box[leg_s]
  5. Am I assigning these form variables to the array the most efficient way? HTML: <form> <input type="text" name="box1" > <input type="text" name="box2" > <input type="text" name="box3" > <input type="text" name="box4" > </form> PHP: $price = array("leg_s"=>$_POST['box1'], "leg_m"=>$_POST['box2], "leg_l"=>$_POST['box3'], "leg_xl"=>$_POST['box4']);
  6. wildteen88 I will try the serialize() method since the data is for a menu board and if the machine that is running the scripts is reset then I lose all data. I will start testing and let everyone know if I run into any problems. Thanks!
  7. I have two php pages that communicate with each other by writing data to a text file. one page collects data from the user and on submit the script creates an array and then writes it to a text file. The other page is more of a display page gets the array from the text file and echos the data to the page. one of the tricky parts is that the file that the user updates will be pre-populated with the data from the txt file that way the user knows what the old values are. I understand how to create the array. I jsut need help importing and exporting in and out of the scripts from the php files. Is the array still and array? Or does it become a string? Please any help would be awesome just let me know if you need more info. my array will look something like the following. $price = array("leg_s"=>11.99, "leg_m"=>13.99, "leg_l"=>16.99, "leg_xl"=>17.99);
  8. For this function I have a menu board GUI that has 43 areas to add pricing. each row has a column for that pricing area. Does this make sense? Each row would be an update made to the pricing fields. If there is a better way of doing this please let me know. Thanks for your help.
  9. if the box is not checked on submit would that post variable be "false" <input type="checkbox" name="vitamin" checked>
  10. Is it ok to run a for loop to insert data into a database? I have $sql="INSERT INTO prices (box0,box1,box2,box3,box4,box5,box6,box7,box8,box9,box10,box11,box12,box13,box14,box15,box16,box17,box18,box19,box20,box21,box22,box23,box24,box25,box26,box27,box28,box29,box30,box31,box32,box33,box34,box35,box36,box37,box38,box39,box40,box41,box42,box43) VALUES ('$box_0','$box_1','$box_2','$box_3','$box_4','$box_5','$box_6','$box_7','$box_8','$box_9','$box_10','$box_11','$box_12','$box_13','$box_14','$box_15','$box_16','$box_17','$box_18','$box_19','$box_20','$box_21','$box_22','$box_23','$box_24','$box_25','$box_26','$box_27','$box_28','$box_29','$box_30','$box_31','$box_32','$box_33','$box_34','$box_35','$box_36','$box_37','$box_38','$box_39','$box_40','$box_41','$box_42','$box_43')"; mysql_query($sql) or die(mysql_error()); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die(mysql_error()); it would be less of a mess if i could loop through it but I am not sure if this is good practice or not. Any thoughts would be awesome.
  11. I am stuck in an infinite loop and I am getting an undefined error if(isset($_POST['submit'])){ for ($i = 0; $i < count($_POST['box']); $i++){ $box.$i = $_POST['box'][$i]; echo $box.$i; }
  12. so would my code look something like this if(isset($_POST['submit'])){ for($i = 0, $i <= 43,$i ++){ $box.$i = box[i]; } }
  13. OK I will do it as an array. so all the inputs should be named box[] ? do I have to create and array like flash?
  14. I have 43 input text boxes that I am going to name box0 box1, box2 and so on. is there a trick I can use to assign them once I submit the form. so that I don't have to do $box_1 = $_POST['box1']; some sort of loop and then I am going to have to insert the values into a mySQL database. Any help would be awesome.
  15. Is it easy to use JAVA and PHP? I have someone writing a JAVA app that uses an API to collect data and store it in and XML file. When my PHP page loads I need to initiate the JAVA and once the JAVA is done I am going to parse the XML file using PHP. Is this a practical way of doing this? Any help would be awesome.
  16. The only other format would be a .txt file with a variable name and what it equals then a break and so on.
  17. initially we were talking about a XML file but it can be in any format from my understanding.
  18. Is it possible to import a set of variables from a .txt file that is created by a java api? I need to create a php page wrapped around a java app that uses an api to collect data and it stores the data in an file. I then need to use those variables in my php script. If anyone can point me in the right direction I would greatly appreciate it. Thanks!
  19. Thank you for being patient. Here is another example with a new row added to the database. countkey mocha_sm mocha_md mocha_lg icemocha_sm icemocha_md icemocha_lg lat_cap_sm lat_cap_md lat_cap_lg icelat_sm icelat_md icelat_lg coffee_sm coffee_md coffee_lg icecoffee_sm icecoffee_md icecoffee_lg hotchoc_sm hotchoc_md hotchoc_lg 1 3.33 4.44 5.55 6.66 7.77 8.88 9.99 1.11 2.22 3.33 4.44 5.55 6.66 7.77 8.88 9.99 1.11 2.22 3.33 4.44 5.55 2 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 3 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 4 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 when I query the data base I want to get the final row which is "4 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22 2.22" and I want to all of the entries of the different fields by $query = "SELECT * FROM prices ORDER BY 'countkey' DESC LIMIT 1"; $result = mysql_query($query)or die (mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); that way i can echo them into text fields. <div id="mocha_sm" ><input name="mocha_small" type="text" id="company" size=2 maxlength=5 value="<? echo $row['mocha_sm']; ?>"></div> <div id="mocha_sm" ><input name="mocha_small" type="text" id="company" size=2 maxlength=5 value="<? echo $row['mocha_md']; ?>"></div> <div id="mocha_sm" ><input name="mocha_small" type="text" id="company" size=2 maxlength=5 value="<? echo $row['mocha_lg']; ?>"></div><div id="mocha_sm" ><input name="mocha_small" type="text" id="company" size=2 maxlength=5 value="<? echo $row['mocha_sm']; ?>"></div> etc.......
  20. Rows countkey 1 0 1 1 1 2 when I look at the countkey this is what I am getting. Why are the Row's not incrementing? Could this be my issue?
  21. countkey mocha_sm mocha_md mocha_lg icemocha_sm icemocha_md icemocha_lg lat_cap_sm lat_cap_md lat_cap_lg icelat_sm icelat_md icelat_lg coffee_sm coffee_md coffee_lg icecoffee_sm icecoffee_md icecoffee_lg hotchoc_sm hotchoc_md hotchoc_lg Edit 1 3.33 4.44 5.55 6.66 7.77 8.88 9.99 1.11 2.22 3.33 4.44 5.55 6.66 7.77 8.88 9.99 1.11 2.22 3.33 4.44 5.55 Edit 2 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 8.88 Edit 0 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 9.99 so judging by the entries above all the text fields should be 9.99 but I am still get the numbers from the first row.
  22. $query = "SELECT * FROM prices ORDER BY 'countkey' DESC LIMIT 1"; $result = mysql_query($query)or die (mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); I need to get the last entry in a table and then echo it into text boxes. <div id="mocha_sm" ><input name="mocha_small" type="text" id="company" size=2 maxlength=5 value="<? echo $row['mocha_sm']; ?>"></div> But it only returns the entries in the first row. Does anyone see what I am doing wrong I think my issue is with the countkey field. I have it set to an INT and it auto increments
  23. sorry. Thanks Maq. so would $query = "SELECT * FROM prices ORDER BY countkey DSC LIMIT 1"; $result = mysql_query($query)or die (mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); would this work? I am still getting an 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 'DSC LIMIT 1' at line 1
  24. trying to use php to get the last row... I am using the following code $query = "SELECT * FROM prices WHERE index=(SELECT MAX(index) FROM prices)"; any one see what I am doing wrong?
  25. I didn't need the single quotes around the integers that I was inserting. Thanks everyone! I will use . mysql_error()); for now on.
×
×
  • 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.