EagleAmerican Posted July 23, 2007 Share Posted July 23, 2007 I've been trying and can't get it. I would like the results to come out in alphabetical order according to the parasitename. Here is without me trying: <HTML> <HEAD> <META name="GENERATOR" content="WYSIWYG Web Builder from http://www.irishost.net "> <TITLE>ParasiteDB - Staff Area - New Parasite</TITLE> </HEAD> <BODY bgcolor="#000080" text="#008000"> <IMG src="images/img00002.bmp" width="799" height="77" align="top" style="position:absolute;left:0px;top:0px;width:799px;height:77px;z-index:0"> <DIV style="position:absolute; left:259px; top:76px; width:291px; height:23px; z-index:1" align="center" valign="top"> <FONT style="FONT-SIZE:14pt" color="#FFFF80" face="Tahoma">Staff Area -> Add New Parasite</FONT></DIV> <DIV style="position:absolute; left:14px; top:73px; width:150px; height:31px; z-index:2" align="left" valign="top"> <?php echo 'Hello, <b>Staff</b>.'; ?></DIV> <DIV style="position:absolute; left:278px; top:132px; width:257px; height:91px; z-index:3" align="left" valign="top"> <?php if (isset($_GET['addparasite'])): ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Technical Info:<br /> <textarea name="parasitetechinfo" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('********', 'adaarm_db', '**************'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechinfo = $_POST['parasitetechinfo']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasitetechinfo='$parasitetechinfo'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } $name = @mysql_query('SELECT parasitename FROM parasite'); if (!$name) { exit('<p>Error performing query1: ' . mysql_error() . '</p>'); } $from = @mysql_query('SELECT parasitefrom FROM parasite'); if (!$from) { exit('<p>Error performing query2: ' . mysql_error() . '</p>'); } $genre = @mysql_query('SELECT parasitegenre FROM parasite'); if (!$genre) { exit('<p>Error performing query3: ' . mysql_error() . '</p>'); } $description = @mysql_query('SELECT parasitedescription FROM parasite'); if (!$description) { exit('<p>Error performing query4: ' . mysql_error() . '</p>'); } $techinfo = @mysql_query('SELECT parasitetechinfo FROM parasite'); if (!$techinfo) { exit('<p>Error performing query5: ' . mysql_error() . '</p>'); } $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasitetechinfo FROM parasite") or die(mysql_error()); echo '<p>Parasite list:</p> <TABLE width="736" height="100%" border="1" cellpadding="2" cellspacing="5"><TR> <TD align="left" valign="top" width="161">Name</TD> <TD align="left" valign="top" width="122">From</TD> <TD align="left" valign="top" width="128">Genre</TD> <TD align="left" valign="top" width="161">Description</TD> <TD align="left" valign="top" width="164">Technical Info</TD> </TR>'; while ($row = mysql_fetch_array($sql)) { echo '<tr><td align="left" valign="top" width="161">' . $row['parasitename'] . '</td>'; echo '<td align="left" valign="top" width="122">' . $row['parasitefrom'] . '</td>'; echo '<td align="left" valign="top" width="128">' . $row['parasitegenre'] . '</td>'; echo '<td align="left" valign="top" width="161">' . $row['parasitedescription'] . '</td>'; echo '<td align="left" valign="top" width="164">' . $row['parasitetechinfo'] . '</td></tr>'; } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; endif; ?> </table></DIV> </BODY> </HTML> Thanks, Adam Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 23, 2007 Share Posted July 23, 2007 I edited your post to remove your database password. Quote Link to comment Share on other sites More sharing options...
EagleAmerican Posted July 23, 2007 Author Share Posted July 23, 2007 Thanks! Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted July 23, 2007 Share Posted July 23, 2007 Use order by in ur query followed by a column name from db. Quote Link to comment Share on other sites More sharing options...
EagleAmerican Posted July 23, 2007 Author Share Posted July 23, 2007 I'm sorry. This is my first site in PHP and I have no clue what you mean. Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 23, 2007 Share Posted July 23, 2007 You don't really need this in your code. $name = @mysql_query('SELECT parasitename FROM parasite'); if (!$name) { exit('<p>Error performing query1: ' . mysql_error() . '</p>'); } $from = @mysql_query('SELECT parasitefrom FROM parasite'); if (!$from) { exit('<p>Error performing query2: ' . mysql_error() . '</p>'); } $genre = @mysql_query('SELECT parasitegenre FROM parasite'); if (!$genre) { exit('<p>Error performing query3: ' . mysql_error() . '</p>'); } $description = @mysql_query('SELECT parasitedescription FROM parasite'); if (!$description) { exit('<p>Error performing query4: ' . mysql_error() . '</p>'); } $techinfo = @mysql_query('SELECT parasitetechinfo FROM parasite'); if (!$techinfo) { exit('<p>Error performing query5: ' . mysql_error() . '</p>'); } To order alphabetically change this. SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasitetechinfo FROM parasite to this. SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasitetechinfo FROM parasite ORDER BY parasitename ASC EDIT: You might want to take a look into http://us2.php.net/manual/en/function.mysql-escape-string.php for when inserting data. Quote Link to comment Share on other sites More sharing options...
EagleAmerican Posted July 23, 2007 Author Share Posted July 23, 2007 Thanks it all seems to work great! When the site is finished I will let everyone know and let you see whatyou have helped me accomplish. Thanks so much again, Adam Quote Link to comment 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.