I have a code that has many fingers in it, with much musings about how to do what I am looking for it to do, unthankfully it does not. I am stuck at this point because my code skill does not reach this far, and I can't fix it on my own.. This originally started as a simple drop down menu, now it's become much more, and has gone well beyond my skill set it at now.
Here is what I am attempting to do:
In database Testbed I have two tables that are being interacted with this script.
The first is user the second is testbed.
The usertable has all the names that the pull down menu requires. These names reside in the field user.
The testbed table saves where the name selected in the pull down menu resides, it resides in field fab1
So originally the code is meant to do this:
The form this belongs to allows you to enter data and a make choices from a pull down menu. You select the name in the pull down menu, click submit, it posts to the testbed table under fab1 In this case the name is Andy Kahl which is meant to be in the first Fabricator slot. (the other two are for show right now) If a person needs to edit the name they select an edit option on another page, and a new page pops up with the data filled in that was entered into the testbedtable. This is what that page looks like: edit.php
The first name as said before is Andy Khal, the problem is that as you can see it's not showing up correctly.
This is a page just with the pull down menu script, and the rest to make it work.
<?php
require_once('tb/connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$mysqli->select_db('testbed');
echo '<div id="box4">';
echo '<h2>Fabricators</h2>';
echo '<div id="fab1">';
if (!isset($_GET['id'])) {
$query = "SELECT * FROM data WHERE id = '$id'";
}
else {
$query = "SELECT * FROM data WHERE id = '$id'";
}
$result = $mysqli->query("SELECT * FROM user");
echo "<select name='fab1'>\n";
while($row = $result->fetch_assoc())
{
echo '<option value="' . $row['user'] . '"';
if($row['user'] == $user)
{
echo ' selected';
}
echo '>' . $row['user'] . '</option>\n';
}
?>
<body>
<a href="http://kaboomlabs.com/testbed/box.php">Right Click and Save link as... for Code</a>
</body>
Now the problem is, at least I think it is, it does not access at any time the field $fab1 in the table testbed. Just user.So it doesn't know the name that it needs to pull and show as the original selection from the testbed table, from field fab1.
No I've attempted to get this working on my own, I don't want to use java or any other language to solve this if possible, but to me it seems like it is possible, but for whatever reason this seems like it has never been attempted before.
The reason I am doing this is because as you see on the original edit field there are companies in a pull down menu, there are hundreds of them. I am to use this script for that section as well, I don't want to manually edit the page so that it shows the name correctly, that will add hundreds of lines onto a code. I was hoping to have a table in where the names could be stored, a table where the name submitted would be posted, and an edit page which would pull the data from the posted table and say to the script, "The name in the posted table shows me this, make it so that when you pull the data from the name table that it shows this name as the choice, instead of --None-- first."..
But for some reason it seems impossible. I would not be asking for help if I could solve this on my own, so if anyone can help me it would be greatly appreciated.
Attached is a zip with all files required to make it work , so if you want to test it out on your own computer, please do.
Sorry, I made a mistake with the attachment, and I can't seem to find a way to edit it. I forgot to add the tables to the attachment. Here they are.

New Topic/Question
Reply




MultiQuote





|