• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Populating drop down menu

Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Hi all,

I'm trying to create a page that allows the user to select a case from a drop down menu and in return, the page will print the relevant details.

So far - I've managed to create a drop down menu populated with "M References". I've also managed to get the page to print out all the rows in the mySQL table. However, I can't figure out how to link them together.

Code:
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
    $options .="<option>" . $caseReference['CaseReference'] . "</option>";
}

$menu="<form id='filter' name='filter' method='post' action=''>
  <label>M:</label>
    <select name='filter' id='filter'>
      " . $options . "
    </select>
</form>";

echo $menu;

?>
<tr>
    <td>
      <table border="1">
      <tr>
        <td>Case ID</td>
        <td>Exhibit ID</td>
		<td>Date / Time</td>
		<td>File Size</td>
		<td>Camera Make</td>
		<td>Camera Model</td>
		<td>Height</td>
		<td>Width</td>
		<td>Longitude</td>
		<td>Latitude</td>
		<td>Map</td>
      </tr>
<?php
 while($caseReference = mysql_fetch_array($caseResult)) {
  echo '<tr><td>';
  echo $caseReference['CaseReference'];
  echo '</td><td>';
  echo $caseReference['ExhibitReference'];
  echo '</td><td>';
  echo $caseReference['DateTimeCreated'];
  echo '</td><td>';
  echo $caseReference['FileSize'];
  echo '</td><td>';
  echo $caseReference['CameraMake'];
  echo '</td><td>';
  echo $caseReference['CameraModel'];
  echo '</td><td>';
  echo $caseReference['Height'];
  echo '</td><td>';
  echo $caseReference['Width'];
  echo '</td><td>';
  echo $caseReference['Longitude'];
  echo '</td><td>';
  echo $caseReference['Latitude'];
  echo '</td><td>';
  echo '<a href="https://maps.google.co.uk/maps?q='.$caseReference['Longitude'].',-2.102723">View on map</a>';
  echo '</td></tr>';
} 

 
?>

I know im missing a piece of code, I'm just not sure what to add. Could someone point me in the right direction?

Thanks

:toast:
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
OK, I think I know what you're trying to do. Whenever a value is selected in the drop down menu, you want the table below to update based upon the selection? You would use JavaScript/jQuery and PHP's GET Method to perform this.

Code:
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
    $options .="<option>" . $caseReference['CaseReference'] . "</option>";
}

$menu="
    <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
      " . $options . "
    </select>";

echo $menu;

?>

Now what you need to do is modify your options array to something like this, putting the primary key to your case reference data so it can be taken in using the GET Method when the select listbox is changed and the page is refreshed to update the table below. -

Code:
<option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?>"><?php echo $caseReference['CaseReference']; ?></option>

Now you need to use PHP's GET Method to pull in the primary key for the case reference data so that you can output the data to your table based upon what the user selected in the select listbox.

It would look something like this -
Code:
if (!empty($_GET['caseReference']) && is_numeric($_GET['caseReference'])){
$caseReference = (int) $_GET['caseReference'];
} else {
header('Location: /caseReference.php?caseReference=empty');
}

Let me note that this is not how I would write this particular functionality, but I wanted to stay as close to how you are writing this so you could get the idea.

Why are you putting static HTML into PHP variables? This seems like a head ache to me and it wastes resources IMO.

I suggest avoiding echo'ing HTML via PHP when it is possible. It is a PITA to read, and this way your business logic is seperated from your presentation layer.

Example -
Code:
	<div style="text-align:left;">
	<?php if ($inboxcount == 1 ){ ?>
	<b>Inbox</b> contains <?php echo $inboxcount; ?> message.<br />
	You have <?php echo $pmTotal; ?> messages stored, of a total 100 allowed.<br />
	<?php } else { ?>
	<b>Inbox</b> contains <?php echo $inboxcount; ?> messages.<br />
	You have <?php echo $pmTotal; ?> messages stored, of a total 100 allowed.<br />
	<?php } ?>
	<div id="progressbar"></div><br />
	<b>Jump to a Folder:</b>
	<select style="font-size:1.05em;" onchange="if (this.value) window.location.href=this.value">
		<option value="<?php echo $_SERVER['PHP_SELF']; ?>?p=inbox" selected="selected">Inbox (<?php echo $inboxcount; ?>)</option>
		<option value="<?php echo $_SERVER['PHP_SELF']; ?>?p=sent">Sent (<?php echo $sentcount; ?>)</option>
	</select>
	</div>

Best of luck :D
 
Last edited:
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Thanks for the reply Ross!

Seems a lot more complicated than I first imagined. :laugh:

Looks like Im going to have to read up a bit more on PHP!

As for mixing PHP with HTML - I wasn't aware this was a bad way of programming. I've only just started using PHP. Thanks for the heads up.
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
The only part i'm not 100% following is:

Code:
if (!empty($_GET['caseReference']) && is_numeric($_GET['caseReference'])){
$caseReferencePK = (int) $_GET['caseReferencePK'];
} else {
header('Location: /caseReference.php?caseReference=empty');
}

I'm not sure where to implement this? My primary key in my Database is called PID, so i'm assuming that would replace caseReference PK.
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
You're welcome, no problem. You know the concept of what you're trying to do you just needed a point in the right direction at how to accomplish it.

I forgot to mention, this could also be done using AJAX/jQuery without the PHP GET Method. If you're familiar with using AJAX you could use jQuery's change function on a select listbox to get the primary key and then run a SQL query and return the result set live on the same page without a refresh.
 
Last edited:
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
You're welcome, no problem. You know the concept of what you're trying to do you just needed a point in the right direction at how to accomplish it.

I forgot to mention, this could also be done using AJAX/jQuery without the PHP GET Method. If you're familiar with using AJAX you could use jQuery's change function on a select listbox to get the primary key and then run a SQL query and return the result set live on the same page without a refresh.

My web dev skills go as far as coding a basic template with css. That's about it :roll:
 
Joined
Aug 10, 2007
Messages
4,267 (0.70/day)
Location
Sanford, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
Thanks for the reply Ross!

Seems a lot more complicated than I first imagined. :laugh:

Looks like Im going to have to read up a bit more on PHP!

Also to read: MySQLi or PDO (my choice) for database access.

Zend has been trying to ween people off the MySQL functions for awhile and as of 5.3.0, has started depreciating them. It's not really a problem if you just dabble here or there, but if you want to write code that will survive version upgrades (after depreciation is removal), might want to learn one of the above.
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
The only part i'm not 100% following is:

Code:
if (!empty($_GET['caseReference']) && is_numeric($_GET['caseReference'])){
$caseReferencePK = (int) $_GET['caseReferencePK'];
} else {
header('Location: /caseReference.php?caseReference=empty');
}

I'm not sure where to implement this? My primary key in my Database is called PID, so i'm assuming that would replace caseReference PK

Ah, yes... this would be in the header of your PHP script that also shows the select listbox and table. Basically, run this in the header when you get your PID using the GET Method when the page refreshes after the listbox selection. Then build your table by running a SQL statement after getting the PK based upon the selection from the listbox.

Like this below -

Code:
if (!empty($_GET['caseReference']) && is_numeric($_GET['caseReference'])){
$caseReferencePK = (int) $_GET['caseReference'];
} else {
header('Location: /caseReference.php?caseReference=empty');
}

$caseReference = mysql_query("SELECT * FROM `mcases` WHERE `PID` = '$caseReferencePK' ");
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
I'll give it ago and update with results. Cheers all.
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
I also forgot to mention... When the page is refreshed after a selection is made from the select listbox, you will want to keep the last selection selected.

Here is one way to accomplish that -

Code:
<option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?; ?>" <?php if (!empty($_GET['caseReference']) && $_GET['caseReference'] == $caseReference['CaseReference']) { echo 'selected="selected"'; } ?>> <?php echo $caseReference['CaseReference']; ?></option>

Again, best of luck :D
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
I must be completely missing the point. I've re-read your post four times and tried to make sense of it. I'm sure this is what your asking, although the link is going straight to "/caseReference.php?caseReference=empty"

PHP Header:
Code:
		<?php
		require('mysqlConnect.php');
		$order = "SELECT * FROM `mcases`";
		$caseResult = mysql_query($order);
		
		if (!empty($_GET['caseReference']) && is_numeric($_GET['caseReference'])){
		$caseReferencePK = (int) $_GET['caseReference'];
		} else {
		header('Location: /caseReference.php?caseReference=empty');
		}
		
		$caseReference = mysql_query("SELECT * FROM `mcases` WHERE `PID` = '$caseReferencePK' ");
		?>

Code:
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
    $options .="<option>" . $caseReference['CaseReference'] . "</option>";
}

$menu="
    <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
      " . $options . "
    </select>";
	echo $menu;
?>

<option value="
<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$PID ?>">
<?php echo $caseReference['CaseReference']; ?>
</option>

Then I have the table set out below. Sorry to be a pain!
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
/caseReference.php is what I mean to say your current PHP script. If there is no GET variable set you want it to go to the name of your current PHP script file that has the select option listbox and table output. I put caseReference.php just for an example. Put the name of your PHP script file in place of /caseReference.php

Code:
    <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
<?php
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) { ?>
    <option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?>"><?php echo $caseReference['CaseReference']; ?></option>
<?php } ?>
    </select>

I changed some of your code for the better. Try this above. Your example above mine is only outputting one caseReference primary key in the select listbox. You want each primary key for each caseReference in all of the entries of the select listbox. The above example can accomplish that.

/edit

I also spot another issue. You need something like this instead of what you have above -

Code:
<?php
require('mysqlConnect.php');
$order = "SELECT * FROM `mcases`";
$caseResult = mysql_query($order);

if (!empty($_GET['caseReference']) && is_numeric($_GET['caseReference'])){
$caseReferencePK = (int) $_GET['caseReference'];
$caseReference = mysql_query("SELECT * FROM `mcases` WHERE `PID` = '$caseReferencePK' ");
} else {
header('Location: /caseReference.php?caseReference=empty');
}

?>

I'm sorry but there I realize that this is very hard for me to give better advice without knowing the structure of your database.
 
Last edited:
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Code:
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
    $options .="<option>" . $caseReference['CaseReference'] . "</option>";
}

$menu="
 <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
<?php
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) { ?>
    <option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?>"><?php echo $caseReference['CaseReference']; ?></option>
<?php } ?>
    </select>";
	echo $menu;
?>

<option value="
<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$PID ?>">
<?php echo $caseReference['CaseReference']; ?>
</option>

I seem to have a slight error in my code. I think its to do with closing tags - Just been looking for the last 20 minutes but can't find it. :wtf:
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
$options .="<option>" . $caseReference['CaseReference'] . "</option>";
}

$menu="
<label>M:</label>
<select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
<?php

^^^ You're starting another PHP block before ending
 
Joined
Dec 2, 2009
Messages
3,351 (0.64/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
How weird, i just did today one with numbers :)
Anyway, you can fetch the results from a database and use a foreach inside the select
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
I did try and close it, but it wouldn't seem to allow it. (By allow it I mean, the colour coded coding in notepad++ stayed grey).

I think it might be something to do with the variable $menu. Is that in the correct place?
 
Joined
Jan 9, 2010
Messages
481 (0.09/day)
Location
Kansas
System Name Late 2013 rMBP 13'' w/ 250 GB SSD
Display(s) Dell P2416D @ 2560x1440 & Dell U2211H @ 1920x1080
Audio Device(s) NuForce uDAC-2 w/ Klipsch Promedia 2.1 & Sennheiser HD595
Mouse Logitech G400 @ 1600 DPI
Keyboard Razr Black Widow
Software OS X
Code:
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
    $options .="<option>" . $caseReference['CaseReference'] . "</option>";
}

$menu="
 <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
<?php
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) { ?>
    <option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?>"><?php echo $caseReference['CaseReference']; ?></option>
<?php } ?>
    </select>";
	echo $menu;
?>

You have another problem too, your $menu variable can't start in one PHP block and then continue into another...

Please get out of the habit of echo'ing HTML via PHP now. It will help you a lot, trust me.

Code:
    <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
<?php
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) { ?>
    <option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?>"><?php echo $caseReference['CaseReference']; ?></option>
<?php } ?>
    </select>
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Looks as If I have a lot of reading to with PHP!!

Thanks for your help Ross. I think it's probably better if I go away and research PHP a bit more instead of pestering you with questions. As you've said - it's hard to give advice when you don't know the database structure
 
Joined
Dec 2, 2009
Messages
3,351 (0.64/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
Code:
<?php
$options = '';
$filter=mysql_query("SELECT * FROM `mcases` WHERE `CaseReference` > 0");
while($caseReference = mysql_fetch_array($caseResult)) {
    $options .="<option>" . $caseReference['CaseReference'] . "</option>";
}
?>
$menu="
 <label>M:</label>
    <select id='filter' name='filter' onchange='if (this.value) window.location.href=this.value'>
<?php
$filter=mysql_query("SELECT * FROM mcases WHERE CaseReference > 0");
while($caseReference = mysql_fetch_array($caseResult)) { ?>
    <option value="<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$caseReferencePKGoesHere ?>"><?php echo $caseReference['CaseReference']; ?></option>
<?php } ?>
    </select><?php
	echo $menu;
?>

<option value="
<?php echo $_SERVER['PHP_SELF'].'?caseReference='.$PID ?>">
<?php echo $caseReference['CaseReference']; ?>
</option>

Try this
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Joined
Dec 2, 2009
Messages
3,351 (0.64/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
Wow man your code seems very weird, never seen such weird php programming.
You have copied the code somewhere i guess because making code like this seems non-logic

Tell me what you want to do.

EDIT:Copy the code again above, i edited it.
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Last edited:
Joined
Dec 2, 2009
Messages
3,351 (0.64/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
Ok here is the code, but i did a mistake on purpose so you can learn a lot more from it.
It will work though:
Code:
<select name="name">
<?php
$connect = mysql_connect('localhost', 'root', '123456');
$db = mysql_select_db("iphone");
$query = mysql_query("SELECT * FROM cell");
$names = mysql_fetch_array($query);
foreach ($names as $name):
?>
<option value="<?php echo $name; ?>">
<?php echo $name; ?>
</option>
<?php endforeach; ?>
</select>

<?php
	switch($name){
		case 'samsung':
			echo 'Hello world!';
			break;
	}
?>

Also, change the passwords name and other things to your choices
It sounds very weird to start with such things, as it would not mean any learning at all.
The difficulty doesn't sound for beginners, especially logic.
I did the mysql on purpose, not mysqli because that would complicate things a bit more i guess.
It surprises me your know how to create the database since day 2 :)
Nice work!
 
Joined
Jun 30, 2008
Messages
1,145 (0.20/day)
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
Ok here is the code, but i did a mistake on purpose so you can learn a lot more from it.
It will work though:

Thanks Aleksander, thats probably the best way of learning imo.

Also, change the passwords name and other things to your choices
It sounds very weird to start with such things, as it would not mean any learning at all.
The difficulty doesn't sound for beginners, especially logic.
I did the mysql on purpose, not mysqli because that would complicate things a bit more i guess.
It surprises me your know how to create the database since day 2 :)
Nice work!

I've dabbled with PHP on and off for years, but it was only till recently that I sat down and started to learn it.

Thanks for all your help. I'll dabble with this code and post results.

:toast:
 
Joined
Dec 2, 2009
Messages
3,351 (0.64/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
Top