Jump to content

[SOLVED] DropDown Menus


inferium

Recommended Posts

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.