garyed
Members-
Posts
176 -
Joined
-
Last visited
Everything posted by garyed
-
I appreciate the help but I've been messing with it all day & still haven't gotten it. I can get the pointer back to whatever number I put in the argument but I just get that same number 8 times. I even tried reset() & that helped a little populating the drop down but it locked up the database. If anyone could show me how to fix my code that would be greatly appreciated.
-
I'm having a problem with populating a second drop down menu that needs to be identical to the first from a mysql database. I have about 20 items in the DB & I only want to show the first 9. My code is: <select name="a_type" style="width: 175px;"> <option value="" selected="selected"> None selected</option> <?php $i=1; while (($_produce = mysql_fetch_array($result_produce)) && ($i <=9 )) { $produce_type=$_produce["type"]; $produce_id=$_produce["id"]; $i++; ?> <option value="<?php echo $produce_id; ?>"><?php echo $produce_id; ?> - <?php echo $produce_type; ?> </option> <?php } ?> </select> That works fine in my first drop down menu but the second drop down menu with the same exact code will show items starting at 11 & higher instead of 1 to 9. I haven't tried closing the DB & the reopening it which I assume would work but there are a lot of other variables & things I'd have to check to make sure they don't get effected so I'd rather not. Is there a simple way to solve this?
-
Thanks guys , that worked fine. Instead of using echo $_SERVER['PHP_SELF'] is it OK to just use the url of the same page the form is on?
-
Is there a simple way to keep a yes or no selection in a drop down menu after the page is submitted? <form name="survey" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Satisfied<select name="satisfied"> <option value="yes"> yes </option> <option value="no"> no </option> </select> <input name="submit" type="submit" value="Submit"> </form>
-
Thanks for the help, I'm not sure i understand though (I'm really a novice at this) I don't even know what a pointer is. I thought that "mysql_fetch_array ( $result_walls) " loaded the results into an array. I've got a lot more reading to do. This stuff reminds me of how lost i was when I first started using Linux. The tutorials are great once you get to a certain level but until then its like reading Hieroglyphics.
-
I have two drop down menus in a table side by side being populated exactly the same from a msql database. The first menu populates fine but the second one is blank. They are both supposed to be identical, the same info from the same table so I assume that's my problem. I tried moving the while loop so it encapsulates both drop downs but then it messes up the table structure. I tried changing the name of some of the variables by adding "2" on the end & that didn't work either. Is it because once a while loop is executed it can't be used again on the same instance? Heres my code so far: <tr> <td > <select name="wall_type" size="1" style="width: 175px;" > <?php while ($walls_row=mysql_fetch_array($result_walls)) { $type_name=$walls_row["type"]; $type_id=$walls_row["id"]; ?> <option value="<?php echo $type_id; ?>"><?php echo $type_name; ?> </option> <?php } ?> </select> </td> <td > <select name="wall_type2" size="1" style="width: 175px;"> <?php while ($walls_row2=mysql_fetch_array($result_walls)) { $type_name2=$walls_row2["type"]; $type_id2=$walls_row2["id"]; ?> <option value="<?php echo $type_id2; ?>"><?php echo $type_name2; ?> </option> <?php } ?> </select> </td> </tr>
-
Thanks, That worked perfectly Now I'm trying to understand why. I thought an html tag would not work inside php code but obviously it can if its done right.
-
You'll have to excuse me but I'm a little slow when it comes to this stuff. I don't understand where any of that code goes or what you even mean by referencing the URL . Here's the code I use to get my menu populated. <SELECT NAME="ufactor" style="width:50px;"> <?php while ($row=mysql_fetch_array($result)) { $value=$row["U-value"]; $id=$row["id"]; $thing=$row["type"]; ?> <option value="<?php echo $value; ?>"> <?php echo $id."-".$thing; ?> </option> <?php } ?> </SELECT> Where would your code go?
-
I got some help here about 6 months ago with drop down menus & I need a little more. I'm working on a form that has about 20 drop down menus, each populated from a mysql database table with about 50 entries each. I need to keep the selected menu option on the form after the form is submitted but each time the form is submitted the selected menu option reverts back to the first item in the database table. Is there any practical way to fix this problem other than using javascript to finish up?
-
I got it! It ended up that I didn't have the php-mysql package loaded in PCLinux /Zenmini I found it in synaptic & everything is fine. Thanks for the ideas
-
1 - phpinfo() returns PHP version 5.3.1 2 - Adding the error line to the script I get this: 3 -All I could find in php.ini was: I checked my whole drive & there's no "php_mysql.dll file on it either. I thought .dll files were for windows only. By the way thanks again for the help from the other forum. Everything is working great now on my desktop. I know the code is right because it works on my desktop so I'm hoping its just a setup problem.
-
I'm having a problem either connecting to the databse or to mysql completely. I'm running pclinux zenmini on my laptop with Apache/Php/Mysql installed. I can access mysql databases through the terminal but my php file that accesses it doesn't work through localhost on my web browser. I can run other php programs through the browser on localhost so I know php is working right. I have the same mysql database on my Desktop running Ubuntu & everything works fine through the browser using the same php file. I tried to intentionally put in the wrong password on the desktop to see if I get an error & it says "Could not connect" When I do the same thing on my laptop I don't get any error, just a blank screen. It acts like apache & mysql aren't communicating. Here's how I'm accessing mysql: $link = mysql_connect ("localhost", "root", "password") or die ("Could not connect"); print ("Connected to mysql successfully"); Is there some setup that I could be lacking ? any ideas welcome
-
Wow, thanks that worked perfectly! Now I can upload & import my databases from my home server to my web server with that simple script. To be safe I'll delete the php file from the web server when I'm done & just edit it on my home server. By the way does encasing a command in those ``(tildes) or whatever they're called make it act as though it was typed in a terminal because when I tried the exec() command it didn't work but those things sure did.
-
I am now trying to find a script to import a mysql dump file of a complete database. If I do this in a Linux terminal it works fine. mysql -h host -u user -p password database < dumpfile.sql Is it possible to put this command or something that will do the same thing in a php script?
-
Does this mean that it can't be done through a php script?
-
I'm not sure where the code goes. Do I put it in a php file or do i use it in phpmyadmin or what?
-
Is it possible to run a single script that can select from a mysql database from one server & then transfer the results to another server. The reason is that my webhost (1and1) does not have a way to import from their phpmyadmin program so I can't transfer the work I do on my localhost mysql databases. I've written a simple script that will copy tables from one database into a new database but I can't figure out if there's a way to copy from my localhost to my webhost. include "login_host.php"; $db = "glass"; $_table = "shade"; $db_new= "test3"; $db_create = "create database $db_new"; if (mysql_query($db_create)){ echo "OK - database";} else{ echo "database not created".mysql_error();} mysql_select_db($db_new); if (mysql_query("create table $_table like glass.$_table")) { echo "OK - table"; } else { echo "table not created".mysql_error();} mysql_query ("insert into $_table select * from $db.$_table"); mysql_close($connect);
-
echo "Now I see "; // says the blind man.
-
Why do I need the if statements? What's wrong with doing this? $sql = "select north from wall_type where type='e_Wood Siding R 13';"; $result = mysql_query($sql); $north = mysql_result($result, 0);
-
Thanks, That works perfectly. Now if I could only understand how that code works.
-
I assume this is simple but I can't find a way to do it yet. All I want to do is get one piece of data out of a mysql database & put it into a variable. I know how to use mysql_fetch_array but I don't know how to get what I need out of the array. If I'm on the mysql command line I could type: mysql> select * from wall_type; +-------------------------+------+-------+-------+-----------+-------+-------+ | type | name | north | south | east_west | ne_nw | se_sw | +-------------------------+------+-------+-------+-----------+-------+-------+ | a_Stucco_R11 | a_St | 0.10 | 0.15 | 0.20 | 0.25 | 0.30 | | b_Stucco R13 | b_St | 0.13 | 0.18 | 0.23 | 0.28 | 0.33 | | c_Stucco R19 | c_St | 0.19 | 0.24 | 0.29 | 0.34 | 0.39 | | d_Wood Siding R11 | d_W | 1.10 | 0.60 | 2.10 | 2.60 | 3.10 | | e_Wood Siding R 13| e_W | 1.30 | 1.80 | 2.30 | 2.80 | 3.30 | | f_Wood Siding R19 | f_W | 1.90 | 2.40 | 2.90 | 3.40 | 3.90 | +--------------------------+------+-------+-------+-----------+-------+-------+ 6 rows in set (0.00 sec) mysql> select north from wall_type where type='e_Wood Siding R 13'; +-------+ | north | +-------+ | 1.30 | +-------+ to get the figure "1.30" What would be the php code to get that figure "1.30" into a variable?
-
I must be missing something because I getting errors when I try to use the code in a php page.
-
Thanks again, I'll study the code until I understand it. I really appreciate the help. Gary
-
Well I should have stated that I have about 10 drop boxes each with about 25 choices on the form I'm working on so that might be a little impractical to code it that way. It looks like I might have to stick to javascript for this one. Let's see if I understand it right; php works from the server so after a form is submitted & it does its thing with the variables it reloads the page & that is why the drop boxes will go back to their default settings. It sounds like that would be an interesting function to figure out but its definitely beyond me, at least for now.
-
Wow, thanks Teamatomic That works perfect, I almost understand it but I'm not sure what the " => " means in the array. I see that the order of the boxes follow the numbers in the array. I'm obviously not too sharp on this stuff yet.