5 Years
Discussion Span
Last Post by thearts.beach


assuming you have connected to the database correctly...

$result = mysql_query("select * from table1 where id=$_POST[ID]");
while ($data = mysql_fetch_array($result))
    foreach($data as $k=>$v)
        echo ($k . " = " . $v);

or.. something to that effect... but since we are all moving to mysqli, this is already horridly outdated.

Check out http://www.php.net/manual/en/mysqli.quickstart.statements.php

To expand...

When you query with php, you are asking for a "result" object (or, to be syntactically correct, a resource). You then need to iterate through the object/array/resource/whatever in order to actually get your data.

Edited by ryantroop


Thanks for the pointers to the new scripts,

Have tryied your soulation on the above and get the error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a5153944/public_html/update1phone.php on line 4

so tryied

$result = mysql_query("select * from table1 where id=8");

and got a record set, so my thinking is

this is the inputpage.php form

<FORM method=post action=input1.php>
<P><textarea name=id>input number here</textarea><P>
<INPUT value="Submit Query" type=submit>


Edited by thearts.beach: inline code


thanks @ryantroop

but since we are all moving to mysqli, this is already horridly outdated.

Check out http://www.php.net/manual/en/mysqli.quickstart.statements.phpHere

if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

$res = $mysqli->query("SELECT id, area FROM plate1 WHERE id =('$_POST[id]')");
$row = $res->fetch_assoc();

printf("id = %s (%s)\n", $row['id'], gettype($row['id']));
printf("label = %s (%s)\n", $row['area'], gettype($row['area']));
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.