inferium Posted December 5, 2008 Share Posted December 5, 2008 Hey everyone, PHP n00b here. Here's my problem: A couple of months ago, I had someone build a basic script for me, and it won't work for me because it incorporates dropdown menus which he left for me to fill. My understanding of PHP is horrible (I've been trying to learn, but I learn with baby-steps). So anyways, we try to run this script and apparently it won't work until the dropdown menus have been populated with data. So, is there a good tutorial out there that will help me fill these in? I simply just don't know where to begin to look. Thanks everyone! https://1minloans.com/roman2/admin/form.php and the entire source for this script is in a .rar file at https://1minloans.com/roman2.rar Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/ Share on other sites More sharing options...
bgadberry Posted December 5, 2008 Share Posted December 5, 2008 After looking at the code, it appears the code is auto-filling your drop downs with data from the SQL database... this code right here is doing it... <?php //added this to make it show PHP syntax, this isnt there in YOUR php file by this code, but at the top; $result = mysql_query("SELECT * FROM tblbody ORDER BY btype ASC"); $num_rows = mysql_num_rows($result); if ($num_rows == 0) { echo '<option value="">No Body Types</option>'; } else { echo '<option value="">Choose Body Type</option>'; while($row = mysql_fetch_array($result)) { echo '<option ' . ($cbody==$row['bID'] ? 'selected' : '') . ' value="'.$row['bID'].'">'.$row['btype'].'</option>'; } } ?>//closing PHP syntax code. What you are looking for in your SQL table is inside THIS table SELECT * FROM tblbody ORDER BY btype ASC What that is basically saying is grab ALL the information from the table tblbody and order by btype (which I assume is body type). So, to fill out your drop downs, you should fill in that table. Same goes with the drive types and any other drop downs you need. Hope it leads you to where you need to go. Your question seems to be a more an SQL question if you dont know how to insert rows and so forth. Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-706951 Share on other sites More sharing options...
inferium Posted December 5, 2008 Author Share Posted December 5, 2008 Hmm... That's really informative, thanks Though, I'm not finding anything anywhere that uses the name tblbody Would this be something I need to create do you think? Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-706960 Share on other sites More sharing options...
bgadberry Posted December 5, 2008 Share Posted December 5, 2008 I would bet you probably havent created it yet if it keeps erroring as it wont work until those fields are there. If you look inside your .rar file, you'll notice a file called SQL.txt. That is an SQL dump from phpmyadmin, which is an awesome package to work with SQL databases. Assuming you have that installed or root access to the server your SQL db is on, you can upload and use that file to create and populate your databases, I took a look and while it doesnt have a lot of information in it, it does have your tables you need and the structure of said tables. Id look into importing that through phpmyadmin if you can. Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-706965 Share on other sites More sharing options...
inferium Posted December 5, 2008 Author Share Posted December 5, 2008 Ah, thanks! I'll try messing with it and see if I can get it to work Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-706972 Share on other sites More sharing options...
inferium Posted December 5, 2008 Author Share Posted December 5, 2008 OK, so I've imported that file through phpmyadmin, and the values still aren't showing up. Is there a specific area where I should import them to? I'll try messing with it some more and see if maybe I overlooked something. Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-706985 Share on other sites More sharing options...
br3nn4n Posted December 5, 2008 Share Posted December 5, 2008 I would turn on php error reporting. did you put the data in a TABLE named tblbody? Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-706998 Share on other sites More sharing options...
inferium Posted December 5, 2008 Author Share Posted December 5, 2008 I'm pretty sure I did When I try to import it again, I get this: Error SQL query: -- -- Database: `dbcars` -- -- -------------------------------------------------------- -- -- Table structure for table `tblbody` -- CREATE TABLE `tblbody` ( `bID` int( 11 ) NOT NULL AUTO_INCREMENT , `btype` varchar( 60 ) NOT NULL , PRIMARY KEY ( `bID` ) ) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =7; MySQL said: Documentation #1050 - Table 'tblbody' already exists Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-707003 Share on other sites More sharing options...
inferium Posted December 5, 2008 Author Share Posted December 5, 2008 I figured it out! I just had to rename some values in the dbconnect file that was referenced in the beginning of the php file. Now I'm having troubles with the uploading of image files (they aren't going in), but at least the error is gone! Thanks guys!!! Quote Link to comment https://forums.phpfreaks.com/topic/135688-solved-dropdown-menus/#findComment-707021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.