O'Reilly Forums: Pulling Data From Two Tables To Show In A Drop Down Menu. - O'Reilly Forums

Jump to content

  • 5 Pages +
  • « First
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • You cannot reply to this topic

Pulling Data From Two Tables To Show In A Drop Down Menu. Output data to show in drop down menu for editing.

#81 User is offline   drewdin 

  • Veteran Member
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 494
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

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
0

#82 User is offline   Matt Ridge 

  • Active Member
  • PipPipPipPipPip
  • Group: Members
  • Posts: 173
  • Joined: 31-August 11

Posted 13 February 2012 - 06:31 PM

View Postdrewdin, 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


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.
0

#83 User is offline   Matt Ridge 

  • Active Member
  • PipPipPipPipPip
  • Group: Members
  • Posts: 173
  • Joined: 31-August 11

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:

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

0

#84 User is offline   drewdin 

  • Veteran Member
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 494
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

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())

0

#85 User is offline   Matt Ridge 

  • Active Member
  • PipPipPipPipPip
  • Group: Members
  • Posts: 173
  • Joined: 31-August 11

Posted 16 February 2012 - 11:47 AM

View Postdrewdin, on 16 February 2012 - 11:40 AM, said:

I don't think you are using this right, you might want to check out php.net

if (mysqli_connect_errno())




would it be better if I do this?

or die ('Error connecting to the MySQL server.');

0

#86 User is offline   drewdin 

  • Veteran Member
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 494
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

Posted 17 February 2012 - 01:44 PM

View PostMatt Ridge, on 16 February 2012 - 11:47 AM, said:

would it be better if I do this?

or die ('Error connecting to the MySQL server.');



what did the documentation say?
0

Share this topic:


  • 5 Pages +
  • « First
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users