Jump to content
Larry Ullman's Book Forums

Confused Guy

Members
  • Posts

    2
  • Joined

  • Last visited

Confused Guy's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. The drop down list is populated with the name of different tables in the database. By selecting a certain value from the drop down list, the table will be populated with the values from the db $sql="CREATE TABLE Bellow1600cc( Name varchar(10), Vehicle varchar(20), PowerKW int(3), TorqueNM int(4) )"; $sql="CREATE TABLE Diesel( Name varchar(10), Vehicle varchar(20), PowerKW int(3), TorqueNM int(4) )"; all the table attributes are the same, just table names and values are different
  2. Hi Im having a problem populating a table when selecting different options from the drop down list(DDL) Heres my code: This is for the DDL Please select Catergory: <select name="cat"> <option value="n" > Choose one </option> <option value="Bellow1600cc" > Below 1600cc </option> <option value="Diesel" > Diesel </option> <option value="1600cc" > 1600cc </option> <option value="1800cc" > 1800cc </option> <option value="2000cc" > 2000cc </option> <option value="ko3Turbo" > ko3Turbo </option> <option value="ko4Turbo" > ko4Turbo </option> <option value="6Cyl" > 6Cyl </option> <option value="6CylTurbo" > 6CylTurbo </option> <option value="8Cyl" > 8Cyl </option> <option value="4CylAftermarket" > 4CylAftermarket </option> </select> And this is the php code: <?php $con=mysql_connect("localhost","root",""); if(!$con) { die("could not connect".mysql_error()); } mysql_select_db("DynoWarsPS",$con); $query="SELECT * FROM $_POST['cat']"; $result=mysql_query($query,$con); $num = mysql_num_rows($result); $title =" "; if(isset($_POST['cat'])) { if($_POST["cat"] == 'Bellow1600cc') { $title ="Below 1600cc"; } else if($_POST["cat"] == 'Diesel') { $title ="Diesel"; } else if($_POST["cat"] == '1600cc') { $title ="1600cc"; } else if($_POST["cat"] == '1800cc') { $title ="1800cc"; } else if($_POST["cat"] == '2000cc') { $title ="2000cc"; } else if($_POST["cat"] == 'ko3Turbo') { $title ="ko3Turbo"; } else if($_POST["cat"] == 'ko4Turbo') { $title ="ko4Turbo"; } else if($_POST["cat"] == '6Cyl') { $title ="6Cyl"; } else if($_POST["cat"] == '6CylTurbo') { $title ="6CylTurbo"; } else if($_POST["cat"] == '8Cyl') { $title ="8Cyl"; } else if($_POST["cat"] == '4CylAftermarket') { $title ="4CylAftermarket"; } } echo"<h2> $title </h2>"; echo "<table border=1 align=center> <tr> <th>Name</th> <th>Vehicle</th> <th>PowerKW</th> <th>TorqueNM</th> </tr> "; while($Arr=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>". $Arr['Name']. "</td>"; echo "<td>". $Arr['Vehicle']. "</td>"; echo "<td>". $Arr['PowerKW']. "</td>"; echo "<td>". $Arr['TorqueNM']. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Im not sure why it doesnt work,
×
×
  • Create New...