Results 1 to 6 of 6
  1. #1
    thomase is offline Member
    Join Date
    Mar 2009
    Posts
    19
    Rep Power
    0

    Default php issue (a little different from java I know!)

    Hi, I'm having a bit of trouble trying to get this to work. I know, it is PHP, but it is still similar to java so someone might have an idea of how to fix it :).

    The aim is, if $_GET[service] is there it'll run something to only display the data where the id ($result[id]) is also in the other table ($whichtable). If the ID is there when it loops to find the ID it'll display the page which processes the info (include('advanceincludes/bussinfo.php').

    With this, it will currently loop through ONCE and find one correct result. I need it to, once it's found this correct result to loop through again until every result that had an ID in the other table also is displayed (eg, all 18 of them as specificed in $amountOfResults).

    I accept there may be better ways of doing this. I have uploaded a picture of what it looks like when it runs (the company shown will be different, depending on which ID it picks to loop through on $result[id] first).

    PHP Code:
    if($_GET[service]){
    $arraytotalnew2 = 0;
    $amountOfResults = 18; // this will be changed to something which actually counts it later
    $streamhostquery = mysql_query("SELECT bussid FROM $whichtable WHERE $_GET[service]='y'") or die("Can't select from the sub catagory product table");
    $arraytotal = 0;
    //this was in the while to limit how many times it runs $arraytotalnew2 < $arraytotal &&
    
    while($result = mysql_fetch_array($query)){
    while($streamhostresult = mysql_fetch_array($streamhostquery)){
    
    
    echo"before == if :   $streamhostresult[bussid]  | $result[id] | $arraytotal  | $arraytotalnew2 <br/>";
    
    if($streamhostresult[bussid] == $result[id] && $arraytotalnew2 != $amountOfResults){
    
    include('advanceincludes/bussinfo.php');
    $totalonpage = $totalonpage + 1;
    $totalextraFeatures = $totalextraFeatures + 1;
    echo"$streamhostresult[bussid] == $result[id] - if | $arraytotalnew2  <br/>";
    $arraytotalnew2 = $arraytotalnew2 + 1;
    
    }//if (id == id)
    
    }//while (streamhostresult)
    
    }//while (result[id])
    }//first if (services?)
    else{
    
    while($result = mysql_fetch_array($query)){
    include('advanceincludes/bussinfo.php');
    $totalonpage = $totalonpage + 1;
    $totalextraFeatures = $totalextraFeatures + 1;
    }
    
    }
    I kind of know I need to get it to loop through the result[id] or something. It's not an assignment, just some work I'm doing for a website of mine. It's annoying as this is the last thing before a beta version can be launched (started last summer :P).
    Attached Thumbnails Attached Thumbnails php issue (a little different from java I know!)-demo.jpg  

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    While we're on the topic of unrelated subjects, my car, a Honda Accord has been making a funny whistling sound whenever I try to turn right. Any ideas on what this could be?

  3. #3
    thomase is offline Member
    Join Date
    Mar 2009
    Posts
    19
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    While we're on the topic of unrelated subjects, my car, a Honda Accord has been making a funny whistling sound whenever I try to turn right. Any ideas on what this could be?
    Hmm, at least mine's programming related...just turn all those echos into system.out.printlns and assume I've already declared those variables :).

    I have posted for help on more relevant forums, but I figured java and php have similarities considering it was influenced by java.

  4. #4
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    you should try describing your issues better. your first sentence already made no sense in helpfully describing anything.

  5. #5
    thomase is offline Member
    Join Date
    Mar 2009
    Posts
    19
    Rep Power
    0

    Default

    Okay, I've changed what I've done and got a little closer with a different script. When this one problem is fixed I think it could work properly. If asking for php help here is a problem I'll stop.

    Basically, when the code below runs it'll output this...How come the bussID: XXXX loop only runs for the first one, and not for each of the userID: xxxx? If that makes sense? I need to check each userID against the bussIDs...and if they match it'll echo "woo" (well, in real life it'll do something better, but for testing that's fine!)

    userID: 3193



    bussID: 3223
    bussID: 3226
    bussID: 3243
    bussID: 3193 woo
    bussID: 3242
    bussID: 3196
    bussID: 3241
    bussID: 3240
    bussID: 3238
    bussID: 3239
    bussID: 3221
    bussID: 3220
    bussID: 3217
    bussID: 3218
    bussID: 3224
    bussID: 3225
    bussID: 3222
    bussID: 3219



    userID: 3221


    userID: 3219

    PHP Code:
    //let's get all the user IDs from the users table
    while($result = mysql_fetch_array($query)){
    echo "<br/>userID: $result[id] ";
    
    echo"<br/><br/><br/>"; //TRIAL FORMATTING ONLY - REMOVE LATER
    
    //Get the bussIDs and do any of these IDs match any of the bussIDs in the other services table?
    while($extraServicesResult = mysql_fetch_array($extraServices)){
    echo "<br/>bussID: $extraServicesResult[bussid] ";
    
    //if they do, let's output the data for that company
    if($extraServicesResult[bussid] == $result[id]){
    
    echo"woo";    // include('advanceincludes/bussinfo.php'); (correct output when all working)
    }
    }//end of while($extraServicesResult
    
    echo"<br/><br/><br/>"; //TRIAL FORMATTING ONLY - REMOVE LATER
    }

  6. #6
    thomase is offline Member
    Join Date
    Mar 2009
    Posts
    19
    Rep Power
    0

    Default

    DOH! Figured it out...was drifting off to sleep, wondering why it didn't work...then I twigged! Had to get up - woo hoo! It works :D

Similar Threads

  1. building automation software java issue
    By BASman in forum Advanced Java
    Replies: 6
    Last Post: 03-15-2009, 08:52 PM
  2. JRE 1.5.0_6 version issue in java Applets
    By raj_java in forum Java Applets
    Replies: 1
    Last Post: 02-21-2009, 03:25 AM
  3. Java Applet Issue
    By bmw4l1f3 in forum New To Java
    Replies: 9
    Last Post: 11-13-2008, 04:39 PM
  4. MySQL + Java - auto incrementation issue
    By int80 in forum Advanced Java
    Replies: 6
    Last Post: 07-29-2008, 06:04 PM
  5. how to issue the command of Ctrl-C (copy) in Java
    By bilal_ali_java in forum Advanced Java
    Replies: 0
    Last Post: 07-18-2007, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •