@ItayMeir
Nothing here yet.
Nothing here yet.
No blogs yet.
ok, is this code ok now? will it work? $con = mysqli_connect("host", "user", "pass", "db"); $query = mysqli_query($con, 'SELECT * FROM `jaralele` ORDER BY `index` DESC LIMIT 3'); $response = mysqli_fetch_assoc($query); $response[success] = false; while($row = mysqli_fetch_array($query)){ $response["success"] = true; $response["index"] = index; $response["title"] = title; $response["comment"] = comment; } echo json_encode($response);
Hi, first of all thank you! just to be sure, what are these lines do? $statement = mysqli_prepare($con, "SELECT * FROM jaralele ORDER BY index DESC LIMIT 3); mysqli_stmt_bind_param($statement, "iss", $index, $title, $comment); mysqli_stmt_execute($statement); mysqli_stmt_store_result($statement); mysqli_stmt_bind_result($statement, $index, $title, $comment); $response = array(); $response["success"] = false; I found them in the internet and used them with the login system.. also I need all rows to be returned like this: while(mysqli_stmt_fetch($statement)){ $response["success"] = true; $response["index"] = $index; $response["title"] = $title; $response["comment"] = $comment; } echo json_encode($response); getting them inside a variable and then returning the variable at the end. is that possible like you did just splitting it and using a variable instead of echo?
OK, so I have a table that has 3 Variables: int index (auto increment), String title, String comment. I want the PHP code to take the last 3 rows of the table (the rows with the biggest indexes), and return them to the java code I already built to use them. I dont know how to code PHP and therefore I don't know what to do after the "import" of the variables from the MySQL table. And thank you vary much for doing this!
OK, if I do, my problem is I don't know how to get them to work at the end of the code. I have this old code that I did to get one row and it worked fine. but I'm not sure how to do the same but with multiple rows.. Old Code: <?php $con = mysqli_connect("", "", "", ""); $index = $_POST["index"]; $statement = mysqli_prepare($con, "SELECT * FROM jaralele WHERE index = ?"); mysqli_stmt_bind_param($statement, "iss", $index, $title, $comment); mysqli_stmt_execute($statement); mysqli_stmt_store_result($statement); mysqli_stmt_bind_result($statement, $index, $title, $comment); $response = array(); $response["success"] = false; while(mysqli_stmt_fetch($statement)){ $response["success"] = true; $response["index"] = $index; $response["title"] = $title; $response["comment"] = $comment; } echo json_encode($response); ?>