kendallkamikaze Posted April 8, 2009 Share Posted April 8, 2009 Fairly simple code, yet the post isnt working. Everything but the DOB part is working. Code goes from this page: <TR><td class='tablegreen' rowspan='2'>Points/Price/Gender/Age</td></tr> <tr><td class='tabletd'><center><BR> <font size='2pt'><I> You must fill out all areas! </font> </I><BR><form action="horse_searchage.php" method="post"> Gender: <select name="Gender"> <option>Mare</option> <option>Stallion</option> <option>Gelding</option> </select> <br> Price Less Than: <input type="text" name="price"> <br> Points Greater Than: <input type="text" name="Points"><BR> Age Less Than: <input type="text" name="DOB"><BR> <input type="submit" value="View Horses for Sale"> </form></font></td></tr> To this page <?php include 'header.php'; ?> <h2> Results of Your Search: </h2> <TABLE BORDER='0' WIDTH='740' CELLSPACING='2' CELLPADDING='1'> <font-face='verdana' size='1'> <tbody> <TR> <td bgcolor='CBEC74' width='300' ALIGN='CENTER'><font size='2pt'><B> Horses Name </b></font></td> <td bgcolor='CBEC74' width='300' ALIGN='CENTER'><font size='2pt'><B> Breed</b></font></td> <td bgcolor='CBEC74' width='70' ALIGN='CENTER'><font size='2pt'><B>Points</b></font></td> <td bgcolor='CBEC74' width='70' ALIGN='CENTER'><font size='2pt'> <B>Age</B></font></td> <td bgcolor='CBEC74' width='70' ALIGN='CENTER'><font size='2pt'><B>Owner</b></font></td></tr> <?php $Gender=$_POST['Gender']; $Points=$_POST['Points']; $DOB=$_POST['DOB']; $price=$_POST['price']; $result = mysql_query("SELECT * FROM horsedata WHERE Gender='$Gender' and price > $price and Points > $Points AND DOB < $DOB order by Points desc"); $color1 = 'D9D9C7'; // Set Color 1 $color2 = 'EFEFE3'; // Set Color 2 $i = 0; // Start at 0 almost always while($r=mysql_fetch_array($result)){ $color = ($i%2) ? $color1 : $color2; // Choose a color by doing some math $id=$r["id"]; $Name=$r["Name"]; $Owner=$r["Owner"]; $Breed=$r["Breed"]; $DOB=$r["DOB"]; $Exp=$r["Exp"]; $Gender=$r["Gender"]; $Points=$r["Points"]; $Height=$r["Height"]; $Registrations=$r["Registrations"]; $Records=$r["Records"]; $Speed=$r["Speed"]; $Scope=$r["Scope"]; $Endurance=$r["Endurance"]; $Power=$r["Power"]; $Obedience=$r["Obedience"]; $Sociability=$r["Sociability"]; $Intelligence=$r["Intelligence"]; $Sire=$r["Sire"]; $Dam=$r["Dam"]; $Foals=$r["Foals"]; $Awards=$r["Awards"]; $price=$r["price"]; $Image=$r["Image"]; //display the row echo " <TR> <td bgcolor='$color' width='300' ALIGN='CENTER'><font size='2pt'> <a href='horse_individual.php?id=$id'>$Name</a></td> <td bgcolor='$color' width='300' ALIGN='CENTER'><font size='2pt'> $Breed</font></td> <td bgcolor='$color' width='70' ALIGN='CENTER'><font size='2pt'> $Points</font></td> <td bgcolor='$color' width='70' ALIGN='CENTER'><font size='2pt'> $DOB</font></td> <td bgcolor='$color' width='70' ALIGN='CENTER'><font size='2pt'> $price</font></td> <td bgcolor='$color' width='70' ALIGN='CENTER'><font size='2pt'> <a href='player_individual.php?id=$Owner'>$Owner</a></font></td> </tr>"; $i++; // Increase $i by one } ?> </table> <br><br> <?php include 'footer.php'; ?> Link to comment https://forums.phpfreaks.com/topic/153227-post-isnt-working/ Share on other sites More sharing options...
Maq Posted April 8, 2009 Share Posted April 8, 2009 Hmm, looks fine to me, are you echoing it out to see where it gets lost? Link to comment https://forums.phpfreaks.com/topic/153227-post-isnt-working/#findComment-804930 Share on other sites More sharing options...
Zhadus Posted April 8, 2009 Share Posted April 8, 2009 Is it not transferring to the page as a POST or you're not getting a result from the query? Echo out the contents of $_POST['DOB'] before you run the query and see the value it's holding. If that's fine, separate the query string from the query itself and echo the string to the screen and make sure it looks correct. Link to comment https://forums.phpfreaks.com/topic/153227-post-isnt-working/#findComment-804931 Share on other sites More sharing options...
kendallkamikaze Posted April 8, 2009 Author Share Posted April 8, 2009 Quote Is it not transferring to the page as a POST or you're not getting a result from the query? Echo out the contents of $_POST['DOB'] before you run the query and see the value it's holding. If that's fine, separate the query string from the query itself and echo the string to the screen and make sure it looks correct. I'm very new at php and i dont know how to echo things out to test :/ Link to comment https://forums.phpfreaks.com/topic/153227-post-isnt-working/#findComment-804950 Share on other sites More sharing options...
Maq Posted April 8, 2009 Share Posted April 8, 2009 echo $DOB; Link to comment https://forums.phpfreaks.com/topic/153227-post-isnt-working/#findComment-804953 Share on other sites More sharing options...
Zhadus Posted April 9, 2009 Share Posted April 9, 2009 Here is a bit more thorough example of what I was trying to explain. I've taken a segment of your code and added the bits that I'd recommend running and that should help you find out the issue: <?php $Gender=$_POST['Gender']; $Points=$_POST['Points']; $DOB=$_POST['DOB']; $price=$_POST['price']; echo "DOB: $DOB <br />"; $query = "SELECT * FROM horsedata WHERE Gender='$Gender' and price > $price and Points > $Points AND DOB < $DOB order by Points desc"; echo "Query: $query <br />"; $result = mysql_query($query); $color1 = 'D9D9C7'; // Set Color 1 $color2 = 'EFEFE3'; // Set Color 2 $i = 0; // Start at 0 almost always while($r=mysql_fetch_array($result)){ ?> You'll notice I've separate your query into a query and a query string. This way we can make sure that PHP is reading it correctly and passing the right variables into the query. It should output: DOB: <dob value> Query: <query string> Make sure that those two lines are exactly what you expect the values to have. Link to comment https://forums.phpfreaks.com/topic/153227-post-isnt-working/#findComment-805500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.