PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$sql = sprintf(" SELECT * FROM `crud_` WHERE `id` = '%s'",
mysql_real_escape_string($id) .";");
//if you put @ PHP will ignore and not display any error message that function outputs
$res = mysql_query($sql) or die(echo "Query failed because: " .mysql_error());
if ($res) {
//testing purposes
$output ="Data: <hr />'';
while ($row = mysql_fetch_assoc($res)) {
// don' t put variables that refer to array values in a string -recipe for problems
$output .= "First Name :{" .$row['fname'] ."} <br>" . "username :{" $row['uname'] ."} <br>" . "email : {" .$row['email'] ."} <br>" . "phone :{".$row['phone'] ."} <br>";
}
//same as before
$output .="<hr />";
return $output;
}
// if you return the output directly you don' t need to add else unless you have a different string for $output
$sql = sprintf(" SELECT * FROM `crud_` WHERE `id` = '%s'",
mysql_real_escape_string($id) .";");
//if you put @ PHP will ignore and not display any error message that function outputs
$res = mysql_query($sql) or die(echo "Query failed because: " .mysql_error());
if ($res) {
//testing purposes
$output ="Data: <hr />'';
while ($row = mysql_fetch_assoc($res)) {
// don' t put variables that refer to array values in a string -recipe for problems
$output .= "First Name :{" .$row['fname'] ."} <br>" . "username :{" $row['uname'] ."} <br>" . "email : {" .$row['email'] ."} <br>" . "phone :{".$row['phone'] ."} <br>";
}
//same as before
$output .="<hr />";
return $output;
}
// if you return the output directly you don' t need to add else unless you have a different string for $output
$listUsers = readUsers(1);
if($listUsers)
{
print $listUsers;
}
var_dump($listUsers);
if($listUsers == false)
{
print "no users or this is an error!";
}
works but only gives me one row from the db :S
maybe take out the where id part and just select all ? :S