Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help a PHP noob

Name: Anonymous 2013-08-12 10:30

Hi guys. Just started tinkering in PHP.
I made a form with a dropdown box which get populated from a MYSQL database. like this:

<form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<?php
echo  "<select name='search' onChange='this.form.submit()'>";
    while ($row = mysql_fetch_array($result)) {
        echo "<option value='" . $row['ID'] . "'>" . $row['ID'] . " </option>";
}
?>


This fetches an ID and fills the rest of the form with DB data like this:

$search=$_POST['search'];

$data = 'SELECT * FROM `tlbintake` WHERE `ID` = "'.$search.'"';
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
  $data2 = mysql_fetch_array($query);


Everything works correctly but after selecting an ID from the dropdownbox it fills in all the data correctly but it resets the ID to the "first" ID in the list.

How can I make it show the correct ID in stead of the first one?

Name: Anonymous 2013-08-12 10:32

Entire code for good measure:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
      <title>test</title>
</head>
<body>
<center>

<?php

include "connect.php"; 
mysql_select_db('database_wwp') or die ("Couldn't select database.");

$search=$_POST['search'];

$data = 'SELECT * FROM `tlbintake` WHERE `ID` = "'.$search.'"';
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
  $data2 = mysql_fetch_array($query);
 
 
?>


<!-- Form-->
<form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<TABLE>

<?php
    $sql = "SELECT ID FROM tlbintake";
    $result = mysql_query($sql);
?>
       
<tr><td>Intake ID:</td>
<td>

<?php
echo  "<select name='search' onChange='this.form.submit()'>";
?>

<?php
    while ($row = mysql_fetch_array($result)) {
        echo "<option value='" . $row['ID'] . "'>" . $row['ID'] . " </option>";
            }
?>
</td></tr>
   
   
<tr><td><P></td></tr>
<tr><td>Naam:</td> <td><input type="text" name="NaamVeld" value="<?php echo $data2[Naam]?>"/> <br> </td> </tr>
<tr><td>Adres:</td>  <td><input type="text" name="AdresVeld" value="<?php echo $data2[Adres]?>"/> <br> </td></tr>
<tr><td>Plaats:</td>  <td><input type="text" name="PlaatsVeld" value="<?php echo $data2[Plaats]?>"/> <br></td></tr>
<tr><td>Telefoon:</td>  <td><input type="text" name="TelVeld" value="<?php echo $data2[Tel]?>"/><br></td></tr>
<tr><td>Mobiel:</td>  <td><input type="text" name="MobVeld" value="<?php echo $data2[Mob]?>"/><br><P></td></tr>
<tr><td>Afgegeven:</td>  <td><textarea rows="3" cols="25" name="AfgegevenVeld"/><?php echo $data2[Afgegeven]?></textarea><p></td></tr>
<tr><td>Opmerkingen:</td> <br> <td><textarea rows="6" cols="50" name="OpmerkingenVeld"/><?php echo $data2[Opmerkingen]?></textarea></td></tr>
<tr><td><input type="hidden" name="SleutelVeld" value="<?php echo $search?>"> 
<input type="submit"  value="Opslaan"></td></tr>
</form>
</TABLE>
</center>
</body>
</html>

Name: Anonymous 2013-08-12 10:39

we can be absoluteley 100 per cent totally sure and certain that no black ppl were involved in inventing this. GUARANTEED.

 add blood transfusions and peanut butter and the few other things blacks invented and contributed. that is the plus side of the balance sheet. then subtract high crime and all the cost of lawyers courts judges and victims and incarcerations, all the bastard children who never had a father that cared to stay around, the welfare they disproportionately use, the gang activity and drugs and lives it destroys every day, affirmative action and economic costs of less qualified workers, politics usin race and crying that EVERYBODY they dont like is racist for stupid reasons, urban inner cities nobody can live in or start a business in because of gangs and crime, iq tests we cant use anymore because when blacks do bad nobody dares say maybe blacks have lower iq, no no the test is "biased" etc etc. single mothers are crime factories and most black mothers are single mothers. that dumb uneducated ghetto gutter bitch voting for obama for her "obama money" that obama gets "from his stash", jesse jackson, al sharpton, etc. then the virus of islam and all the blacks who convert to it.

 add up what they contribute one time and subtract what they cost every day. blacks are a net drain on society. admit it. then realize i dont like it either. i wish tehy were better people. but admit it. dont cry about hwo much you hate me for sayin it. it is the truth. admit it.

 put that in your political correctness pipe and smoke it.

Name: Anonymous 2013-08-12 10:52

>>3

wat

Name: Anonymous 2013-08-12 10:52

>>1
FUCK OFF AND DIE

Name: Anonymous 2013-08-12 10:53

$data = 'SELECT * FROM `tlbintake` WHERE `ID` = "'.$search.'"';

>>1
RESURRECT AS A ZOMBIE; THEN FUCK OFF AND SHOOT YOURSELF IN THE BRAIN

Name: Anonymous 2013-08-12 11:00

dem bots.

Name: Anonymous 2013-08-12 11:07

>>3
Kudos to Niggers for destroying the language and the culture of every country in which they are found! Just think about it ... they are the only ethnic group who can be in the USA for more than 1-2 generations without sounding like a native English speaker. Even native Mandarin Chinese speakers who come to the USA have children who sound like native English speakers. Niggers have had how many hundreds of years now? Oh but we're supposed to call it "Ebonics" and pretend like this is somehow not a failure of theirs. Better to fuck up the entire language for everyone than to tell a 13% minority to get with the program. Brilliant! Don't worry, at least that way everyone's widdle feelings won't get hurt. Because that's more important than anything else, right? Right, you pantywaists?!

Name: Anonymous 2013-08-12 11:20

>>8
nigger

Name: Anonymous 2013-08-12 11:27

one word the obvious SQL injection of anus

Name: Anonymous 2013-08-12 11:28

niggers are tonging my anus!

Name: Anonymous 2013-08-12 11:33

>>11
Back to /b/ ``please''!

Name: Anonymous 2013-08-12 11:50

>>1
Just started tinkering in PHP.
Drop it like it's hot.

Name: Anonymous 2013-08-12 11:50

>>12
"please"!

Does this bother you?

Name: Anonymous 2013-08-12 11:58

>>14
Don't bother me, ``please''.

Name: Anonymous 2013-08-13 9:38

im in the second class of PHP with prof. Melgareg this is what he taught me

<?php
    $nombre = "Richar";
    $edad = 5;
    echo "Hola {$nombre} usted tiene {$edad} años";
?>

Name: Anonymous 2013-08-13 9:56

>>1

Best is to drop the PHP, the language sucks. Choose something different. Perl, scheme, ruby, erlang, haskell, python or whatever. Almost everything is better than PHP.

If you are not willing to that, start at least working with a template system. Some are more reasonable than others. It is not difficult to create a simple one yourself (but don't do it with includes). Don't mix logic and representation.

Then the next thing is that HTML is a markup language and you are not using it in a sane matter. Tags should always be closed. The select you use is not closed.

You also fail to sanitize your variables and you are not using prepare statements, which can become a security problem later on.

And you should use PDO or some other database abstraction layer.

First fix these things and then come back asking why your dropdown doesn't behave as it should.

Name: Anonymous 2013-08-13 11:02

>>1
Like >>10,13,17 said. You are better OFF without PHP, so much so, I'd recommend you use PL/pgSQL instead for all your scripting needs than PHP. For the things you need to safeguard against injections, just use procedures and functions.

Name: Anonymous 2013-08-13 13:03

>>18

That sounds good, but you know what? Some brainwashed MVC goofy will come around and starts ranting,
that your database should be used to store data and that the logic of the application cannot be stored in the database because that is not MVC and AS WE KNOW MVC is the only usable design pattern to build a website. And of course you need to include an orm into your design otherwise it is not ENTERPRISE enough. Everybody knows SQL is outdated and not reusable in the sense an ORM model is totally reusable. Why use SQL BTW? You should look to a NoSQL solution, databases are so slow and outdated. Nobody who is vogue uses relational databases anymore, there are difficult to operate. To complex. PL/pgSQL is not javascript, you noted that, javascript is the language of the future and has nodejs, which is the fastest webserver in the whole world  and you can reuse your server side code on the client side. This totally rocks, totally different than PL/pgSQL, which cannot be run client side. How come you try to not use an Object Oriented language. This is the only correct way to construct a program. There are no other paradigms in which extreme programming could be defined so natural, therefore you should use OO instead of your procedural languages. Besides that it is too complex for people to declare if a function is pure or not, because nobody knows what that means and it is not OO anyways.


That is the moment you will think fuck off and leave prog.

Name: Anonymous 2013-08-13 13:44

professor melgareg seems a little bit jew to me

Name: Anonymous 2013-08-13 15:37

>>13
Laughed harder than I should have

Name: Anonymous 2013-09-15 18:09

                            ██████████████████████                                                                          
          ██████████████████                      ████            ██████████████    ████    ██    ██  ██████    ████    ██    ██
        ██                      ██                    ████  ████████████████████  ██    ██  ██    ██  ██      ██    ██  ██  ██
        ██                  ████            ██            ████    ██████████████  ██        ████████  ████    ██        ████
          ██████████████████          ██████                ██    ██████████████  ██    ██  ██    ██  ██      ██    ██  ██  ██
                        ██        ████    ██                ██    ██████████████    ████    ██    ██  ██████    ████    ██    ██
                        ██████████        ██                ██    ██████████████                                            
                          ██          ████  ██              ██    ██████████████  ██████████  ██    ██  ██████  ██      ██  
                            ██████████      ██              ██    ██████████████      ██      ██    ██  ██      ████  ████  
                              ██        ████  ██            ██    ██████████████      ██      ████████  ████    ██  ██  ██  
                                ████████      ██            ██    ██████████████      ██      ██    ██  ██      ██      ██  
                                ██        ████              ██    ██████████████      ██      ██    ██  ██████  ██      ██  
                                  ████████            ████████    ██████████████                                            
                                          ████████████      ████████████████████                                            
                                                                  ██████████████

Name: Anonymous 2013-09-15 18:26

I think does PHP its job pretty well

Name: Anonymous 2013-09-16 5:36

do dat dere code in .net and use mssql fukken n00b

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List