O'Reilly Forums: Pulling Data From Two Tables To Show In A Drop Down Menu. - O'Reilly Forums
Pulling Data From Two Tables To Show In A Drop Down Menu. Output data to show in drop down menu for editing.
#81
Posted 13 February 2012 - 01:51 PM
its not a big deal, i was just trying to say that you dont always get what you expect and it always good to check your results and make sure you have what you expect.
The weirdest things happen when you dont expect it
The weirdest things happen when you dont expect it
#82
Posted 13 February 2012 - 06:31 PM
drewdin, on 13 February 2012 - 01:51 PM, said:
its not a big deal, i was just trying to say that you dont always get what you expect and it always good to check your results and make sure you have what you expect.
The weirdest things happen when you dont expect it
The weirdest things happen when you dont expect it
Oh I know I'll have to adjust the script if I have to, but for now I just need one part working, then I can flesh out the rest if need be.
#83
Posted 16 February 2012 - 02:47 AM
Well you are right, it pulls data from multiple rows at once, even though I thought I took into consideration all scenarios. After dealing with a bug I had which had me bed ridden at home yesterday, I spent some time re-writing the script again from scratch, the problem is i am running into I can't figure out how to stop it from looping...
Well I may be able to, but I really don't know if this will work:
]The only thing is I need to find out a way to make it so that it pulls the data from only one row, and the only way to do that is from testbed using the column "ID"... but that would mean to add more code I think, by making it instead of using like a login script, making it so that if id = 1 type deal... but I have to wait to get to work to try it out. [/size][/color][/font]
Well I may be able to, but I really don't know if this will work:
<?php
// Connect to the database.
require_once('tb/connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (mysqli_connect_errno()) {
die("MySQL failed to connect: " . mysqli_connect_error());
}
$testbed = "SELECT * FROM testbed";
$testbed = mysqli_query($dbc, $testbed) or die("Failed to execute query on tesbed table: " . mysqli_error($dbc));
while ($row = mysqli_fetch_assoc($testbed)){
if (!$row){
echo 'Query Failed<br/><br/>';
}else{
echo 'Query for Testbed Fabricator is : '.$row["fab1"].'<br />';
$fab1_1 = $row["fab1"];
}
$user = "SELECT * FROM user WHERE userid='".$fab1_1."'";
$user = mysqli_query($dbc, $user) or die("Failed to execute query on user table: " . mysqli_error($dbc));
$row = mysqli_fetch_assoc($user);
echo 'Query for User ID # is : '.$row["userid"].', '.$row["user"].'<br /><br />';
}
// Free the result set.
mysqli_free_result($testbed);
mysqli_free_result($user);
?>
]The only thing is I need to find out a way to make it so that it pulls the data from only one row, and the only way to do that is from testbed using the column "ID"... but that would mean to add more code I think, by making it instead of using like a login script, making it so that if id = 1 type deal... but I have to wait to get to work to try it out. [/size][/color][/font]
This post has been edited by Matt Ridge: 16 February 2012 - 02:51 AM
#84
Posted 16 February 2012 - 11:40 AM
I don't think you are using this right, you might want to check out php.net
if (mysqli_connect_errno())



















