Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2004
    Location
    Leamington, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data retrieval problem

    Hi guys,

    im having a problem with my code.
    when a visitor searches for a member the query gets passed to another page & the DB is queried and results displayed

    however the results aren't being displayed ( there are entries in the table )

    here is my code for the search page
    PHP Code:
    <form action="srchres.php" method="get" name="search" id="search">
              <
    table width="318" border="0" cellspacing="0" cellpadding="0">
                <
    tr bgcolor="#E33BE8" class="mediumtxt">
                  <
    td colspan="2"><div align="center"><strong><font color="#FFFFFF">Enter Criteria</font></strong> </div></td>
                </
    tr>
                <
    tr>
                  <
    td width="98" bgcolor="#FEB30A"><div align="left">Age : </div></td>
                  <
    td width="220" bgcolor="#E1E8F2"><div align="left">
                    <
    select name="age" class="mediumtxt" id="age">
                      <
    option value="*" selected>Any</option>
                      <
    option value="BETWEEN 13 AND 20">13 20</option>
                      <
    option value="BETWEEN 21 AND 30">21 30</option>
                      <
    option value="BETWEEN 31 AND 40">31 40</option>
                      <
    option value="BETWEEN 41 AND 50">41 50</option>
                      <
    option value="BETWEEN 51 AND 60">51 60</option>
                      <
    option value="61 >">60+</option>
                      </
    select>
                  </
    div></td>
                </
    tr>
                <
    tr>
                  <
    td bgcolor="#FEB30A"><div align="left">Sex : </div></td>
                  <
    td bgcolor="#E1E8F2"><div align="left">
                    <
    select name="sex" class="mediumtxt" id="sex">
                        <
    option value="Male" selected>Male</option>
                        <
    option value="Female">Female</option>
                    </
    select>
                  </
    div></td>
                </
    tr>
                <
    tr>
                  <
    td bgcolor="#FEB30A"><div align="left">Country : </div></td>
                  <
    td bgcolor="#E1E8F2"><div align="left">
                    <
    select name="country" class="mediumtxt" id="country">
                    <
    option value="*">Any</option>
                      <
    option value="United Kingdom" selected>UK</option>
                      <
    option value="United States">United States</option>
                        
    //Reduced for post            </select>
                  
    </div></td>
                </
    tr>
                <
    tr>
                  <
    td bgcolor="#FEB30A"><div align="left">Sexuality : </div></td>
                  <
    td bgcolor="#E1E8F2"><div align="left">
                    <
    select name="sexuality" class="mediumtxt" id="sexuality">
                      <
    option value="*" selected>Any</option>
                      <
    option value="Straight">Straight</option>
                        <
    option value="Bi-sexual">Bi-sexual</option>
                        <
    option value="Open Minded">Open Minded</option>
                        <
    option value="Gay / Lesbian">Gay Lesbian</option>
                        <
    option value="Rather Not Say">Rather Not Say</option>
                      </
    select>
                  </
    div></td>
                </
    tr>
                <
    tr>
                  <
    td bgcolor="#FEB30A"><div align="left">Race : </div></td>
                  <
    td bgcolor="#E1E8F2"><div align="left">
                    <
    select name="race" class="mediumtxt" id="race">
                       <
    option value="*" selected>Any</option>
                       <
    option value="Asian">Asian</option>
                        <
    option value="Latin / Hispanic">Latin Hispanic</option>
                        <
    option value="Mixed Race">Mixed Race</option>
                        <
    option value="White European">White European</option>
                        <
    option value="Oriental">Oriental</option>
                        <
    option value="African American">African American</option>
                    </
    select>
                  </
    div></td>
                </
    tr>
                <
    tr>
                  <
    td bgcolor="#FEB30A"><div align="left">Body Type : </div></td>
                  <
    td bgcolor="#E1E8F2"><div align="left">
                    <
    select name="body_type" class="mediumtxt" id="body_type">
                      <
    option value="*" selected>Not Bothered</option>
                        <
    option value="Slim / Toned" >Slim Toned</option>
                        <
    option value="Average" >Average</option>
                        <
    option value="Defined" >Defined</option>
                        <
    option value="Medium Build" >Medium Build</option>
                        <
    option value="Fuller Figure" >Fuller Figure</option>
                    </
    select>
                  </
    div></td>
                </
    tr>
                <
    tr>
                  <
    td bgcolor="#FEB30A"><div align="left">Marital Status : </div></td>
                  <
    td bgcolor="#E1E8F2"><div align="left">
                    <
    select name="marital_status" class="mediumtxt" id="marital_status">
                      <
    option value="*" selected>Any</option>
                      <
    option value="Single">Single</option>
                        <
    option value="In Relationship" >In Relationship</option>
                        <
    option value="Engaged" >Engaged</option>
                        <
    option value="Happily Married" >Happily Married</option>
                        <
    option value="Unhappily Married" >Unhappily Married</option>
                        <
    option value="Divorced" >Divorced</option>
                        <
    option value="Widowed" >Widowed</option>
                    </
    select>
                  </
    div></td>
                </
    tr>
              </
    table>
              <
    br>
              <
    input type="submit" class="smalltxt" value="Search">
            </
    form
    and here is the code for the database query on the srchres.php page

    PHP Code:
    $sex $_GET['sex'];
    $country $_GET['country'];
    $newcountry str_replace('+'''$country);
    $sexuality $_GET['sexuality'];
    $race $_GET['race'];
    $body_type $_GET['body_type'];
    $marital_status $_GET['marital_status'];
    $maxRows_memberprofile 10;
    $pageNum_memberprofile 0;
    if (isset(
    $_GET['pageNum_memberprofile'])) {
      
    $pageNum_memberprofile $_GET['pageNum_memberprofile'];
    }
    $startRow_memberprofile $pageNum_memberprofile $maxRows_memberprofile;

    mysql_select_db($database_OnlineFlirting$OnlineFlirting);
    $query_memberprofile "SELECT * FROM members WHERE sex='$sex' AND country='$newcountry' AND sexuality='$sexuality' AND race='$race' AND body_type='$body_type' AND marital_status='$marital_status' AND age ".$_GET['age'];
    $query_limit_memberprofile sprintf("%s LIMIT %d, %d"$query_memberprofile$startRow_memberprofile$maxRows_memberprofile);
    $memberprofile mysql_query($query_limit_memberprofile$OnlineFlirting) or die(mysql_error());
    $row_memberprofile mysql_fetch_assoc($memberprofile);

    if (isset(
    $_GET['totalRows_memberprofile'])) {
      
    $totalRows_memberprofile $_GET['totalRows_memberprofile'];
    } else {
      
    $all_memberprofile mysql_query($query_memberprofile);
      
    $totalRows_memberprofile mysql_num_rows($all_memberprofile);
    }
    $totalPages_memberprofile ceil($totalRows_memberprofile/$maxRows_memberprofile)-1
    and here is the code that displays the results ( still on srchres.php )

    PHP Code:
    <td rowspan="5" valign="top" class="mediumtxt1">
          <div align="center">        <table width="102" height="237" border="0" cellpadding="0" cellspacing="0">
              <tr>
                  <?php do { ?>
                <td width="102"><?php
                
    if($row_memberprofile['ppic']=="Not Set"){
                
    $displaypic "<img src=\"upload/nopicsml.jpg\" width=\"30\" height=\"30\">";
                } else {
                
    $displaypic "<img src=\"$row_memberprofile[ppic]\" width=\"100\" height=\"100\">";;
                }
                
    ?>
                       <?php echo $displaypic;?>
                       <?php echo $row_memberprofile['username']; ?>  </td>
                   <?php } while ($row_memberprofile mysql_fetch_assoc($memberprofile)); ?>
                 </tr>
            
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><a href="<?php printf("%s?pageNum_memberprofile=%d%s"$currentPagemax(0$pageNum_memberprofile 1), $queryString_memberprofile); ?>" class="mediumtxt"><font color="#CC0000">Previous</font></a> | <a href="<?php printf("%s?pageNum_memberprofile=%d%s"$currentPagemin($totalPages_memberprofile$pageNum_memberprofile 1), $queryString_memberprofile); ?>" class="mediumtxt"><font color="#CC0000">Next</font></a></td>
              </tr>
            </table>
    any ideas guys ? Im stumped
    Last edited by MatesOnline; 09-29-2004 at 04:34 AM.

  • #2
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well first off (i doesn't affect your script too much,) why are you using a do .. while loop to get your table results? The first time you loop through it $row would be unset - pointless! (unless I missed something )

  • #3
    New Coder
    Join Date
    Jul 2004
    Location
    Leamington, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi

    dont understand how $row would be unset because the database query is happening on that page. have used teh do while loop on all my scripts and never had any problems with it. thats why im a bit stumped on this

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    A reminder: The difference between a while and a do...while loop is that the while loop will not execute even once if the statement is false and the doo...while loop will execute the loop at least once even if the statement is false.


  •  

    Posting Permissions

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