Jump to content

Selecting Certain Rows


Imtehbegginer

Recommended Posts

[code]<?php
    include 'config.php';
  $result = mysql_query("SELECT char_name FROM characters LIMIT 5")
or die(mysql_error()); 
$echos = $row['char_name'];
echo $echos;
?>[/code]

That's my code, my config.php file connects to mysql. It doesnt show anything, just shows a blank page.
Hey,

you need to use something like mysql_fetch_array like so:

[code]
$result = mysql_query("SELECT char_name FROM characters LIMIT 5") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
    $echos .= $row['char_name'];
}
echo $echos;
[/code]

This will also append the results to the $echos variable, rather than keep overwriting it.

Thanks,
mark

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.