dropfaith Posted May 27, 2012 Share Posted May 27, 2012 this below is the idiot error it submits everything except baby into my database just fine baby = select box like all the others html is fine <?php $gender = $_POST['gender']; $gender1 = $_POST['gender1']; $Species1 = $_POST['Species1']; $Species2 = $_POST['Species2']; $baby = $_Post['baby']; $query="insert into breeding (gender, gender1, Species1, Species2, baby) values ('$gender','$gender1','$Species1','$Species2','$baby')"; $result = mysql_query($query); ?> Okay now for the question the code below im trying to add a counter to it but all the fields need to match so anytime all gender 1 and 2 species 1 and 2 baby match it adds to a counter and displays but only if they all match. Im not sure where to start on that so tips are awesome or instruction since im new to this <?php $query = "SELECT * FROM breeding"; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { // iterate through resultset // print article titles while($row = mysql_fetch_object($result)) { ?> <tr> <td><?php echo $row->gender; ?> <?php echo $row->Species1; ?></td> <td><?php echo $row->gender1; ?> <?php echo $row->Species2; ?></td> <td><?php echo $row->baby; ?></td> <td>HERE ID LIKE TO ECHO TOTAL </td> </tr> <?php } } // if no records present // display message else { ?> <p>No press releases currently available</p> <?php } ?> http://box1.host1free.com/~crimso/breeding.php theres a test link Quote Link to comment https://forums.phpfreaks.com/topic/263194-count-similar-rows-and-an-idiot-error-thats-making-my-brain-hurt/ Share on other sites More sharing options...
requinix Posted May 27, 2012 Share Posted May 27, 2012 1. In PHP variables are case-sensitive. $_POST is not the same as $_Post. 2. Don't use multiple rows with all the same values. Add a column that counts how many there are, then set it to 1 (if the values don't exist yet) or increment it (if the values do exist). Quote Link to comment https://forums.phpfreaks.com/topic/263194-count-similar-rows-and-an-idiot-error-thats-making-my-brain-hurt/#findComment-1348888 Share on other sites More sharing options...
cpd Posted May 27, 2012 Share Posted May 27, 2012 Your SQL statements also suggest your database isn't normalised. You might want to consider Normalising to at the very least 2nd form, 3rd is the norm however. Quote Link to comment https://forums.phpfreaks.com/topic/263194-count-similar-rows-and-an-idiot-error-thats-making-my-brain-hurt/#findComment-1348889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.