Jump to content

Recommended Posts

hi all;

 

I have a little problem which is my sql query does not get all records from db, it take all records-1. I mean if i have 10 records then my query show only 9. here is my sql query

 

<?php
$host_name = "localhost";
$db = "stuff";
$user = "root";
$pass = "123456";
$deli = mysql_pconnect($hostname, $user, $pass) or trigger_error(mysql_error(),E_USER_ERROR); 

mysql_select_db($db, $deli);
$query_r = "SELECT id, Nick_Name FROM stuff_data ORDER BY id ASC";
$r = mysql_query($query_r, $deli) or die(mysql_error());
$row_r = mysql_fetch_assoc($r);
$totalRows_r = mysql_num_rows($r);
?>

 

and here is form code

 

<select name='stuff'>
  	<?php 
	while ($row_r=mysql_fetch_array($r)){		
		$id = $row_r['id'];
		$nick = $row_r['Nick_Name'];
		echo "<option value='$nick' id='$id'>$nick</option>";
		}
	?>
</select>

 

My another major problem is; i develop web pages with UTF-8 default charset and my db collation also UTF-8, when i check data in my tables all i see is wierd characters instead of japanese chars. What do i have to do ?

If my visitors' borwser set SHIFT_JIS as default encoding does is effect result of page viewing or browser will change to UTF-8 automatically ?

 

Great appreciate for any help and advice.

Link to comment
https://forums.phpfreaks.com/topic/137786-japanese-char-and-record-problem/
Share on other sites

I solved record problem.

Here, let me share my experience for others who have same problem.

 

The solution was very easy; in my query i checked the condition at top of loop with

<?php while($row_r=mysql_fetch_array($r)){
...
...
?>

 

but i figured out to check the condition with

 

<?php do{ ?>
...
...
...
<?php } while ($row_r=mysql_fetch_array($r)); ?>

 

This is the solution for getting records.

 

But still i have problem about UTF-8.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.