Jump to content

Another syntax issue


dlyles

Recommended Posts

I promise you guys by the end of the weekend, I'll have this enough to eliminate the need for repeated questions.  In the meantime, can someone give me a heads up as to what's wrong with this basic form?  I'm not getting any errors, but I'm also not seeing anything on the page.  No form, no data...

[code]
<?php
$db = mysql_connect(*******);
mysql_select_db("inventory",$db);

if ($id) {

  // query the DB

  $sql = "SELECT * FROM groups WHERE id=$id";
  $result = mysql_query($sql);
  $myrow = mysql_fetch_array($result);


  ?>



  <form method="post" action="<?php echo $PHP_SELF?>">

  <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

  Group Name:<input type="Text" name="groupname" value="<?php echo $myrow["GroupName"] ?>"><br>



  <input type="Submit" name="submit" value="Enter information">

  </form>

  <?php

} else {

  // display list of Groups

  $result = mysql_query("SELECT * FROM groups",$db);
echo $result;
  while ($myrow = mysql_fetch_array($result)) {
$group=$row['GroupName'];
echo $row['GroupName'];


  }

}

?>
[/code]
Link to comment
Share on other sites

i'll take a shot in the dark and guess u have globals on?

well for one this could be fixed "<?php echo $PHP_SELF?>" should be "<?php echo $PHP_SELF; ?>"
but that shouldn't cause the problem

Looks like when submitting your showing them the form again instead of the page. What you want to do is more something like this:
[code]
<?php
$db = mysql_connect(*******);
mysql_select_db("inventory",$db);

  // query the DB

  $sql = "SELECT * FROM groups WHERE id=$id";
  $result = mysql_query($sql);
  $myrow = mysql_fetch_array($result);

if (!isset($id)) {
  ?>



  <form method="post" action="<?php echo $PHP_SELF; ?>">

  <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

  Group Name:<input type="Text" name="groupname" value="<?php echo $myrow["GroupName"] ?>"><br>



  <input type="Submit" name="submit" value="Enter information">

  </form>

  <?php

} else {

  // display list of Groups

  $result = mysql_query("SELECT * FROM groups",$db);
echo $result;
  while ($myrow = mysql_fetch_array($result)) {
$group=$row['GroupName'];
echo $row['GroupName'];


  }

}

?>
[/code]
Link to comment
Share on other sites

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.