Asked  2 Years ago    Answers:  5   Viewed   63 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

3
$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>";
Thursday, September 1, 2022
3

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.

Sunday, October 16, 2022
 
latkin
 
1

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>'; 
} 
Sunday, September 25, 2022
1

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

Sunday, August 14, 2022
1

It seems that following command works in newer versions of DB2.

TRUNCATE TABLE someschema.sometable IMMEDIATE  
Wednesday, September 28, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 

Browse Other Code Languages