Jump to content

[HELP] Editing Page


darish
Go to solution Solved by Muddy_Funster,

Recommended Posts

[m]include "config.php";
$id=$_GET['id'];
$qry=mysql_query("select * from register where id='$id'");
$count=mysql_num_rows($qry);
while($get=mysql_fetch_array($qry))
{$radio=$get['active'];?>


Primeiro Nome





Ultimo Nome





Numero






Email





Cidade






Empresa





Morada





 

Submit

 

 

 

Its and EDITING PAGE.

But the only thing its working = When I change the name on "Morada" ... it changes the name of "email" instead ... and thats the only thing that is working :S , maybe u can send me a code of update? :S 

 

Link to comment
Share on other sites

Please not when posting code to wrap it within


tags or click the <> button in the editor.

 

 

But the only thing its working = When I change the name on "Morada" ... it changes the name of "email" instead

The only thing I can suggest is to make sure you have used unique names for the Email and Morada form fields and that you are using the correct variables in the php code where it updates these fields.

Link to comment
Share on other sites

<?php
include "config.php";
$id=$_GET['id'];
$qry=mysql_query("select * from register where id='$id'");
$count=mysql_num_rows($qry);
while($get=mysql_fetch_array($qry))
{$radio=$get['active'];?> 
                       
  <tr>
                          <th width="40%">Primeiro Nome</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Nome" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['fname']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
  <tr>
                          <th width="40%">Ultimo Nome</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Intrudos Apelido" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['lname']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
  <tr>
                          <th width="40%">Numero</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['mobile']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 
 <tr>
                          <th width="40%">Email</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['email']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 <tr>
                          <th width="40%">Cidade</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['city']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 
 <tr>
                          <th width="40%">Empresa</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['company']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 <tr>
                          <th width="40%">Morada</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['address']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>

I think this will be good now :S , so it only changes the last one -.- ("morada" in this case) and it changes email instead :/

Edited by darish
Link to comment
Share on other sites

I told you not to declare the function multiple times, declare it only once at the start of your page and then refference it mutiple times:

function myFunct(){
...
}
...
...onClick = "myFunct()"...
...
...onChange = "myFunct()"...
...

If you have made changes to your code please repost the new code with the current behaviour:  What it doesn't do + What it does do + What it should do | and include a summary of your changes.  help us to help you.

Edited by Muddy_Funster
Link to comment
Share on other sites

 

             <tbody>
<?php
include "config.php";
$id=$_GET['id'];
$qry=mysql_query("select * from register where id='$id'");
$count=mysql_num_rows($qry);
while($get=mysql_fetch_array($qry))
{$radio=$get['active'];?> 
                       
  <tr>
                          <th width="40%">Primeiro Nome</th>
                          <th>
<input type="text"  name="fname"class="form-control" placeholder="Introduz Nome" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['fname']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
  <tr>
                          <th width="40%">Ultimo Nome</th>
                          <th>
<input type="text"  name="lname"class="form-control" placeholder="Intrudos Apelido" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['lname']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
  <tr>
                          <th width="40%">Numero</th>
                          <th>
<input type="text"  name="mobile"class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['mobile']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 
 <tr>
                          <th width="40%">Email</th>
                          <th>
<input type="text"  name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['email']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 <tr>
                          <th width="40%">Cidade</th>
                          <th>
<input type="text"  name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['city']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 
 <tr>
                          <th width="40%">Empresa</th>
                          <th>
<input type="text"  name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['company']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 <tr>
                          <th width="40%">Morada</th>
                          <th>
<input type="text"  name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['address']; ?>" required>
 <script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
        </th></tr>
 
 
 
 
                       <tr>
                          <th>Activo/Suspendido</th>
                          <td>
   Activo<input type='radio' name='radio' id='radio' value="1" <?php if ($radio=='1') echo "checked=checked";  ?>/>
   Suspendido<input type='radio' name='radio' id='radio' value="0" <?php if ($radio=='0')  echo "checked=checked";  ?>/>
    <input type="hidden" name="id" value="<?php echo $_GET['id'];?>" />
             <input type="hidden" value="Submit" name="submit" />
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <header class="panel-heading"><div align="center"><button type="submit" class="btn btn-primary">Editar</button></div></header></form>
                    
                    <?php } ?>

 

what it doesnt do : It doesnt edit at all :S

what it does do : it shows all the things from the data base, and it only edit the "email" , thats the only thing that it works o.O

what should do : Edit all 7 things .. not only the email :S 

Link to comment
Share on other sites

you are still decalring the same function multiple times, move the function decleration out of the loop above the table code.  and try changing your code to something more like to following (it's been a long time since I used mysql_ so it will probably need a bit of tweeking:

 

<script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
...
<tbody>
<?php
include "config.php";
$id=$_GET['id'];
$qry=mysql_query("select * from register where id='$id'");
$count=mysql_num_rows($qry);
$results = =mysql_fetch_assoc($qry);
foreach($results as $row){
    if($row['active'] == 1){
        $ckeckboxes = "<td>   Activo<input type='radio' name='radio' id='radio' value='1' checked='checked' />\n\r    Suspendido<input type='radio' name='radio' id='radio' value='0' />";
    }
    else{
        $ckeckboxes = "<td>   Activo<input type='radio' name='radio' id='radio' value='1' />\n\r    Suspendido<input type='radio' name='radio' id='radio' value='0' checked='checked' />";
    }
    $pageOut = <<<PAGEOUT
        <tr>
        <th width="40%">Primeiro Nome</th>
        <th><input type="text"  name="fname" class="form-control" placeholder="Introduz Nome" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['fname']}" required></th>
        </tr>
        <tr>
        <th width="40%">Ultimo Nome</th>
        <th><input type="text"  name="lname" class="form-control" placeholder="Intrudos Apelido" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['lname']}" required></th>
        </tr>
        <tr>
        <th width="40%">Numero</th>
        <th><input type="text"  name="mobile" class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['mobile']}" required></th>
        </tr>
        <tr>
        <th width="40%">Email</th>
        <th><input type="text"  name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['email']}" required></th>
        </tr>
        <tr>
        <th width="40%">Cidade</th>
        <th><input type="text"  name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['city']}" required></th>
        </tr>
        <tr>
        <th width="40%">Empresa</th>
        <th><input type="text"  name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['company']}" required></th>
        </tr>
        <tr>
        <th width="40%">Morada</th>
        <th><input type="text"  name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['address']}" required></th>
        </tr>
        <tr>
        <th>Activo/Suspendido</th>
        {$checkboxes}
        <input type="hidden" name="id" value="{$_GET['id']}" />
        <input type="hidden" value="Submit" name="submit" />
        </td>
        </tr>
PAGEOUT;
echo $output;
}
echo "</tbody> \n\r </table> \n\r <header class='panel-heading'><div align='center'><button type='submit' class='btn btn-primary'>Editar</button></div></header></form>"
?>
Link to comment
Share on other sites

right, I have this working with the test data included - by working I meen that it renders the table on screen and provides individual buttons for each from.

<script>
function alpha(e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
</script>
...
<table>
<tbody>
<?php
//Your Database Connection Code:
/*
include "config.php";
$id=$_GET['id'];
$qry=mysql_query("select * from register where id='$id'");
$count=mysql_num_rows($qry);
$results = mysql_fetch_assoc($qry);
*/

//offline test dataset to map out variables into table elements
$results = array(
    array(
        'id'=>'1',
        'active'=>'1',
        'fname'=>'Adam',
        'lname'=>'Zacharia',
        'mobile'=>'0125555225',
        'email'=>'adam@your.net',
        'city'=>'New Heaven',
        'company'=>'Angel Investment Inc',
        'address'=>'123 wherever lane, 905668'
    ),
    array(
        'id'=>'2',
        'active'=>'0',
        'fname'=>'Charles',
        'lname'=>'Lindberg',
        'mobile'=>'0168755225',
        'email'=>'Chic@your.net',
        'city'=>'Old Hampshire',
        'company'=>'Global Avionics LTD',
        'address'=>'456 nowhere place, 998768'
    )
);
// end of test data

foreach($results as $key=>$row){
    if($row['active'] == 1){
        $checkboxes = "<td>   Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' checked='checked' />\n\r    Suspendido<input type='radio' name='radio' id='radio' value='0' />";
    }
    else{
        $checkboxes = "<td>   Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' />\n\r    Suspendido<input type='radio' name='radio' id='radio' value='0' checked='checked' />";
    }
    $pageOut = <<<PAGEOUT
        <form method="POST" action='#'>
        <tr>
        <th width="40%">Primeiro Nome</th>
        <th><input type="text"  name="fname" class="form-control" placeholder="Introduz Nome" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['fname']}" required></th>
        </tr>
        <tr>
        <th width="40%">Ultimo Nome</th>
        <th><input type="text"  name="lname" class="form-control" placeholder="Intrudos Apelido" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['lname']}" required></th>
        </tr>
        <tr>
        <th width="40%">Numero</th>
        <th><input type="text"  name="mobile" class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['mobile']}" required></th>
        </tr>
        <tr>
        <th width="40%">Email</th>
        <th><input type="text"  name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['email']}" required></th>
        </tr>
        <tr>
        <th width="40%">Cidade</th>
        <th><input type="text"  name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['city']}" required></th>
        </tr>
        <tr>
        <th width="40%">Empresa</th>
        <th><input type="text"  name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['company']}" required></th>
        </tr>
        <tr>
        <th width="40%">Morada</th>
        <th><input type="text"  name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['address']}" required></th>
        </tr>
        <tr>
        <th>Activo/Suspendido</th>
        {$checkboxes}
        <input type="hidden" name="id" value="{$row['id']}" />
        <input type="hidden" value="Submit" name="submit" />
        </td>
        </tr>
        <tr>
        <td><header class='panel-heading'><div align='center'><button type='submit' class='btn btn-primary'>Editar</button></div></header></td><td></td>
        </tr>
        </form>
PAGEOUT;
echo $pageOut;
}
echo "</tbody> \n\r </table> \n\r "
?>

see how that gets on.

Edited by Muddy_Funster
Link to comment
Share on other sites

I can't help any with the CSS, since it's not in the included code, but paste this into the appropriate part of the code I gave you to see an example of how to catch the info from the form:

...
// end of test data

//sample catch form output:
if(!isset($_POST['submit'])){
}
else{
    echo"<pre>";
    print_r($_POST);
    echo "</pre>";
}

//end sample form catch

    foreach($results as $key=>$row){
        if($row['active'] == 1){
            $checkboxes = "<td>   Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' checked='checked' />\n\r    Suspendido<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='0' />";
        }
        else{
            $checkboxes = "<td>   Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' />\n\r    Suspendido<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='0' checked='checked' />";
        }
...
Edited by Muddy_Funster
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.