If... else

My if… else statements do not seem to be working and I can’t figure out what I seem to do be doing wrong. I’m hoping that if the edit_id of the url is 3, then generate text from the database plus a form. Otherwise, just generate text from the database. Whatever I do, the form seems to appear regardless. Any help would be appreciated.

<?php

$edit_id=$_GET['edit_id'];

require_once('connectvars.php');

$query = sprintf("SELECT * FROM editorial WHERE edit_id='$edit_id'");
$result = mysql_query($query);

if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\
";
    $message .= 'Whole query: ' . $query;
    die($message);
}

while ($row = mysql_fetch_assoc($result)) {
if ($edit_id = "3") {
 echo $row['edit_text'];

 echo '<br><br>


 <form method="post" action="sendorder.php">
    <fieldset>

<ul><ul>
<table><tr>

<td><label for="company">Company/Organization</label><br>
<input size=25 type="company" id="company" name="company" /></td>


<td><label for="first_name">First Name</label><br>
<input size=25 type="text" id="first_name" name="first_name" /></td>
<td><label for="last_name">Last Name</label><br>
<input size=25 type="text" id="last_name" name="last_name" /></td>

</tr><tr>
<td><label for="title">Title</label><br>
<input size=25 type="text" id="title" name="title" /></td>


<td><label for="phone">Phone</label><br>
<input size=25 type="text" id="phone" name="phone" /></td>

<td> <label for="email">Email</label><br>
<input size=25 type="text" id="email" name="email" /></td>


</tr></table>

  <label for="comments">Comments</label><br>
<textarea rows="8" cols="70" wrap="physical" name="comments"> </textarea>
<br>
 <input type="submit" value="Submit" name="submit" /><br><br>
    </fieldset>

  </form><br>';
}

else {
 echo $row['edit_text'];

}}

?> 

if ($edit_id == 3)

well that was silly! Thank you very much… that solved it for me… woot!

Your equations set $edit_id equal to 3 every time doing this

[LEFT][COLOR=#007700][FONT=monospace]if ([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$edit_id [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"3"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]) {

[/FONT][/COLOR][/LEFT] wonshikee has properly pointed out how to properly use equal-to.

My left eye is twitching … Please -for your own sake- use [fphp]mysql_real_escape_string[/fphp] before you include unknown variables in a query :slight_smile:

Sound advice, but perhaps you should also get your eye checked out, wouldn’t want to be spreading whatever you got.