Jump to content

Recommended Posts

I am a noob, having trouble with a script I am making.

A drop down select form, and a table output.

 

The Problem is on page load, the first time a user looks at the page all records are displayed, which can take a long time to load.

 

I would like to not populate the table output until user clicks the submit button, but any fix is welcome

I have included the script code and appreciate your help.

 

<?php require_once('../Connections/Lw.php'); ?>
<?php

//Database Class Connect
mysql_select_db($database_Lw, $Lw);
$query_Class = "SELECT `Class` FROM class_list ORDER BY id ASC";
$Class = mysql_query($query_Class, $Lw) or die(mysql_error());
$row_Class = mysql_fetch_assoc($Class);
$totalRows_Class = mysql_num_rows($Class);


//Database Cards Connect
$name = $_POST['select'];
mysql_select_db($database_Lw, $Lw);
$query_Cards = "SELECT Name, `Class`, Drops, Details FROM skill_cards WHERE skill_cards.`Class` LIKE '$name%' ORDER BY Name ASC";
$Cards = mysql_query($query_Cards, $Lw) or die(mysql_error());
$row_Cards = mysql_fetch_assoc($Cards);
$totalRows_Cards = mysql_num_rows($Cards);


<body>
<form id="form1" name="form1" method="post" action="">
 <label>Class
 <select name="select">
  <option value="">ALL</option>
   <?php
do {  
?>
   <option value="<?php echo $row_Class['Class']?>"><?php echo $row_Class['Class']?></option>
   <?php
} while ($row_Class = mysql_fetch_assoc($Class));
 $rows = mysql_num_rows($Class);
 if($rows > 0) {
     mysql_data_seek($Class, 0);
  $row_Class = mysql_fetch_assoc($Class);
 }
?>
 </select>
 </label>
<input type="submit" name="submit" value="submit">
</form>
<table border="1" cellpadding="5" cellspacing="5">
 <tr>
   <td>Name</td>
   <td>Class</td>
   <td>Drops</td>
   <td>Details</td>
 </tr>
 <?php do { ?>
   <tr>
     <td><?php echo $row_Cards['Name']; ?></td>
     <td><?php echo $row_Cards['Class']; ?></td>
     <td><?php echo $row_Cards['Drops']; ?></td>
     <td><?php echo $row_Cards['Details']; ?></td>
   </tr>
   <?php } while ($row_Cards = mysql_fetch_assoc($Cards)); ?>
</table>
<br />
</body>
</html>
<?php
mysql_free_result($Class);

mysql_free_result($Cards);
?>

 

well I have tried a lot of diffrent things, trying to put if statement with the query and such...now I am trying to put the if statement with the table output it thought that it will not display table unless if statement is true...

this is the current code piece I am playing with.

if ($name == “^.+”)
{
<table border="1" cellpadding="5" cellspacing="5">
  <tr>
    <td>Name</td>
    <td>Class</td>
    <td>Drops</td>
    <td>Details</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Cards['Name']; ?></td>
      <td><?php echo $row_Cards['Class']; ?></td>
      <td><?php echo $row_Cards['Drops']; ?></td>
      <td><?php echo $row_Cards['Details']; ?></td>
    </tr>
    <?php } while ($row_Cards = mysql_fetch_assoc($Cards)); ?>
</table>
}
else
{
echo “Please Select<br>”;
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.