Asked  7 Months ago    Answers:  5   Viewed   25 times

i want to echo out everything from a particular query. If echo $res I only get one of the strings. If I change the 2nd mysql_result argument I can get the 2nd, 2rd etc but what I want is all of them, echoed out one after the other. How can I turn a mysql result into something I can use?

I tried:

$query="SELECT * FROM MY_TABLE";
$results = mysql_query($query);
$res = mysql_result($results, 0);

while ($res->fetchInto($row)) {
    echo "<form id="$row[0]" name="$row[0]" method=post action=""><td style="border-bottom:1px solid black">$row[0]</td><td style="border-bottom:1px solid black"><input type=hidden name="remove" value="$row[0]"><input type=submit value=Remove></td><tr></form>n";
}

 Answers

26
$sql = "SELECT * FROM MY_TABLE";
$result = mysqli_query($conn, $sql); // First parameter is just return of "mysqli_connect()" function
echo "<br>";
echo "<table border='1'>";
while ($row = mysqli_fetch_assoc($result)) { // Important line !!! Check summary get row on array ..
    echo "<tr>";
    foreach ($row as $field => $value) { // I you want you can right this line like this: foreach($row as $value) {
        echo "<td>" . $value . "</td>"; // I just did not use "htmlspecialchars()" function. 
    }
    echo "</tr>";
}
echo "</table>";
Wednesday, March 31, 2021
 
Hat
answered 7 Months ago
Hat
99

Try:

echo $Result['StructuredXMLResume']['ContactInfo']['PersonName']['FullName'];

For the EmployerOrgName, as there's more than 1 of these entries, you'll need a foreach loop to get them all, like so:

foreach($Result['StructuredXMLResume']['EmployerOrg'] as $x){
    echo $x['EmployerOrgName'] . '<br />';
}

For the gender:

echo $Result['StructuredXMLResume']['ResumeAdditionalItems']['ResumeAdditionalItem'][0]['Gender'];

I can't say for sure if this is correct as the array is very diffifcult to read through but from what I can gather, this is correct.

The best way, for you, to find these things for yourself, is printing smaller sections of the array, for example:

print_r($Result['StructuredXMLResume']['ContactInfo']);

With this, you'll see that there are other elements in there but you're not having the screen cluttered up by the rest of the array.

Saturday, May 29, 2021
 
Powering
answered 5 Months ago
71

you can't print the result from mysqli_query, it is mysqli_resource and for dumping the error you need to change mysql_error() to mysqli_error()

$username = "bob";
$db = mysqli_connect("localhost", "username", "password", "user_data");
$sql1 = "select id from user_information where username='$username'";
$result = mysqli_query($db, $sql1) or die(mysqli_error());
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { 
    echo $row['id'].'<br>'; 
} 
Saturday, May 29, 2021
 
pamelus
answered 5 Months ago
39

yo need create the user "pma" in mysql or change this lines(user and password for mysql):

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma'; 
$cfg['Servers'][$i]['controlpass'] = '';

Linux: /etc/phpmyadmin/config.inc.php

Tuesday, July 13, 2021
 
ShadowZzz
answered 4 Months ago
79
foreach ($array as $key => $val) {
   echo $val;
}
Thursday, August 12, 2021
 
jyriand
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :