[PHP] เขียนอะไรผิดครับ ช่วยที ไม่มีค่าแสดงออกมา!!!!

เริ่มโดย dekjaidee, 20 กรกฎาคม 2018, 02:10:32

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

dekjaidee


<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
$db_query=mysql_query($sqlhr);
$reshr=mysql_fetch_array($db_query);
$numtxt=$reshr[numtxt];

echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>




จาก Code ด้านบนครับ ค่า $numtxt ไม่มีค่าไรแสดงออกมา ไม่ทราบว่าเขียนผิดตรงไหนครับ
รบกวนทีครับ

:wanwan017: :wanwan017:
HOW TO??

narincr

อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 02:10:32

<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
$db_query=mysql_query($sqlhr);
$reshr=mysql_fetch_array($db_query);
$numtxt=$reshr[numtxt];

echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>


จาก Code ด้านบนครับ ค่า $numtxt ไม่มีค่าไรแสดงออกมา ไม่ทราบว่าเขียนผิดตรงไหนครับ
รบกวนทีครับ

:wanwan017: :wanwan017:

$numtxt=$reshr[numtxt];
ค่า $reshr จะ return เป็น array ครับ
ให้เปลี่ยนเป็น $numtxt=$reshr[0][numtxt];

แบบนี้ครับ ลองดูครับ
รับทำเว็บไซท์ แก้ไข Script CMS  โปรเจ็คนักศึกษา Script PHP ทุกชนิด รับงานเร่ง งานด่วน รับภายใน 3-5 วัน โทรหรือ Line มาคุยกันได้ครับ
DO-PHP.COM , DO-PHP.COM , DO-PHP.COM
Mobile : 092-1064587 , Line : narin.php Email : narin.cr@gmail.com

dekjaidee

อ้างถึงจาก: narincr ใน 20 กรกฎาคม 2018, 02:22:44
อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 02:10:32

<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
$db_query=mysql_query($sqlhr);
$reshr=mysql_fetch_array($db_query);
$numtxt=$reshr[numtxt];

echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>


จาก Code ด้านบนครับ ค่า $numtxt ไม่มีค่าไรแสดงออกมา ไม่ทราบว่าเขียนผิดตรงไหนครับ
รบกวนทีครับ

:wanwan017: :wanwan017:

$numtxt=$reshr[numtxt];
ค่า $reshr จะ return เป็น array ครับ
ให้เปลี่ยนเป็น $numtxt=$reshr[0][numtxt];

แบบนี้ครับ ลองดูครับ

$sqlhr="select * from horotest where numb='$strs'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[0][numtxt];

อย่างนี้เปล่าครับ ถ้าตามนี้ ก็ยังไม่แสดงครับ

:wanwan017: :wanwan017:
HOW TO??

sinomoney

[direct=http://www.thaiseoboard.com/index.php/topic,438918.0.html]โปรแกรมโพสเว็บบอร์ด[/direct] ระบบโพสบน Server ไม่ต้องติดตั้ง ทดลองฟรี
[direct=https://backlink-seo.com]โปรแกรมทำ Backlink[/direct] CommentBlog ใช้งานบนเว็บ ทดลองฟรี

dekjaidee

อ้างถึงจาก: sinomoney ใน 20 กรกฎาคม 2018, 04:18:09
เปิด PHP แบบเต็มด้วยครับ

<?php

?>

เปิดตามนี้แล้วครับ แต่ยังไม่แสดงครับ

:wanwan017: :wanwan017:
HOW TO??

del555

อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 02:28:59
อ้างถึงจาก: narincr ใน 20 กรกฎาคม 2018, 02:22:44
อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 02:10:32

<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
$db_query=mysql_query($sqlhr);
$reshr=mysql_fetch_array($db_query);
$numtxt=$reshr[numtxt];

echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>


จาก Code ด้านบนครับ ค่า $numtxt ไม่มีค่าไรแสดงออกมา ไม่ทราบว่าเขียนผิดตรงไหนครับ
รบกวนทีครับ

:wanwan017: :wanwan017:

$numtxt=$reshr[numtxt];
ค่า $reshr จะ return เป็น array ครับ
ให้เปลี่ยนเป็น $numtxt=$reshr[0][numtxt];

แบบนี้ครับ ลองดูครับ

$sqlhr="select * from horotest where numb='$strs'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[0][numtxt];

อย่างนี้เปล่าครับ ถ้าตามนี้ ก็ยังไม่แสดงครับ

:wanwan017: :wanwan017:

ลองเปลี่ยนจาก $reshr=mysql_fetch_array($db_query);
มาเป็น $reshr=mysql_fetch_assoc($db_query); หน่อยคับ





del555

ลืมอีกอย่างคับ รับค่าแบบนี้นะคับ
$numtxt=$reshr[0][numtxt];





Mrpoohling

<?
require_once "connectdb.php";

$number=$_POST[number];
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='".$strs."'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[numtxt];
   
echo $strs [$numtxt]."<br>";
}
}else{
echo $number;
}
?>
[direct=https://c.lazada.co.th/t/c.bfS0An]9.9 จัดเต็มลดกระหน่ำ[/direct]

dekjaidee

อ้างถึงจาก: Mrpoohling ใน 20 กรกฎาคม 2018, 07:52:32
<?
require_once "connectdb.php";

$number=$_POST[number];
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='".$strs."'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[numtxt];
   
echo $strs [$numtxt]."<br>";
}
}else{
echo $number;
}
?>

ขอบคุณทุกท่านเลยครับ แต่แก้ตามแล้ว ค่า numtxt ก็ยังไม่แสดงครับ

:wanwan017: :wanwan017:
HOW TO??

ten1312

มือใหม่ให้ใช้ echo กับ print_r เยอะๆ
code แค่นี้ให้มันแสดงค่าออกมาทุกแถวก็ยังได้
บันทึกการเรียนเขียน Program
Java :2 พย. 2559 - 19 พย. 2559 หยุดไว้ก่อน
PHP SQL HTML CSS Bootstrap : 25 พย. 2559 - ปัจจุบัน
Javascript jQuery Ajax Angular JS : เรียนผ่านๆยังไม่จริงจัง

[direct=https://www.nanakaset.com]นานาเกษตร[/direct]

Tutorcuu


l3master



CoreBlack.Net รับทำ [direct=https://www.coreblack.net/line-oa-chatbot]แชทบอทไลน์ Line Oa.[/direct] และ แชทบอท Facebook แฟนเพจ
รับออกแบบหน้าเว็บ | พัฒนาเว็บไซต์ | พัฒนาระบบหลังบ้าน | พัฒนา API Service และสคริปต่างๆ

@Add Line ID : boobewc (ให้คำปรึกษาฟรีครับ ออนไลน์เกือบตลอด 24 ชม.)

maneemeena

ตอนผมหัด php ใหม่ๆ แล้วไล่หาบรรทัดเออเรอ ไม่เจอ ผมใช้วิธีการ

die("ผ่าน");

ไล่ทีละแถวเลยครับ  :wanwan020: :wanwan020: :wanwan020:

killer777

ลองไล่ echo ทีละบรรทัดครับ ใช้คำสั่ง  echo ควบคู่กับ exit() จะได้รู้ว่า error ที่บรรทัดไหนครับ

dekjaidee

ตอนนี้ได้แล้วครับ สอบถามเพิ่มเติมอีกนิดครับ

อ้างถึง
<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[numtxt];
   
echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>

กรอก 1111
ค้าที่ได้ก็จะเป็น 11 / 11/ 11 เลขซ้ำกันอ่ะครับ

เราเขียนดักอย่างไรให้แสดงแค่ 11 อย่างเดียวครับ

:wanwan017: :wanwan017:
HOW TO??

Hairremove

[direct= *https://lagraceclinic.com* ]บริการความงามครบวงจร[/direct] >> Lagrace Clinic
[direct= *https://lagraceclinic.com/promotions/hair-removal* ] กำจัดขน ,วิธีกำจัดขน,กำจัดขนด้วยเลเซอร์ [/direct]
[direct= *https://lagraceclinic.com/promotions/hifu* ]  โปรโมชั่น HIFU ,โปรโมชั่นทำไฮฟู  [/direct]
[direct= *https://lagraceclinic.com/promotions/miracle-deep-gold* ]   กำจัดหลุมสิว , สิว , หลุมสิว , กำจัดสิว   [/direct]
แว๊กขน  , ยกกระชับใบหน้า , โปรโมชั่นกำจัดขน , โปรโมชั่นเลเซอร์ , Lagrace Clinic

dekjaidee

อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 14:09:49
ตอนนี้ได้แล้วครับ สอบถามเพิ่มเติมอีกนิดครับ

อ้างถึง
<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[numtxt];
   
echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>

กรอก 1111
ค้าที่ได้ก็จะเป็น 11 / 11/ 11 เลขซ้ำกันอ่ะครับ

เราเขียนดักอย่างไรให้แสดงแค่ 11 อย่างเดียวครับ

:wanwan017: :wanwan017:

:wanwan017: :wanwan017:
HOW TO??

mytony

อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 20:52:14
อ้างถึงจาก: dekjaidee ใน 20 กรกฎาคม 2018, 14:09:49
ตอนนี้ได้แล้วครับ สอบถามเพิ่มเติมอีกนิดครับ

อ้างถึง
<?
require_once "connectdb.php";

$number="$_POST[number]";
if (strlen($number) != 1)
{
$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
//echo substr($number,$i,2)."<br>";
$strs = substr($number,$i,2);

$sqlhr="select * from horotest where numb='$strs'";
   $db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[numtxt];
   
echo "$strs [$numtxt]<br>";
}
}else{
echo "$number";
}
?>

กรอก 1111
ค้าที่ได้ก็จะเป็น 11 / 11/ 11 เลขซ้ำกันอ่ะครับ

เราเขียนดักอย่างไรให้แสดงแค่ 11 อย่างเดียวครับ

:wanwan017: :wanwan017:
ตรงนี้ผิดหรือป่าว
$db_query=mysql_query($sqlhr);
   $reshr=mysql_fetch_array($db_query);
   $numtxt=$reshr[numtxt];
ลองเปลี่ยนตามนี้ดูนะครับ
$db_query=mysqli_query($con,$sqlhr);
$result = mysqli_fetch_assoc($db_query);

รับดูแลแฟนเพจและเว็บไซต์ทั่วไป เช่น เว็บวาไรตี้ เว็บข่าวทั่วไป เว็บข่าวกีฬาราคาเป็นกันเองสนใจ PM  มาได้นะครับ เช่าชุดนาคหาดใหญ่
ขายโดเมน  , book.in.th , server.in.thvpn.in.thmovie.in.thhub.in.th

CherryX

อ้างถึงจาก: maneemeena ใน 20 กรกฎาคม 2018, 10:15:11
ตอนผมหัด php ใหม่ๆ แล้วไล่หาบรรทัดเออเรอ ไม่เจอ ผมใช้วิธีการ

die("ผ่าน");

ไล่ทีละแถวเลยครับ  :wanwan020: :wanwan020: :wanwan020:

ต้องไล่ทีละแถวแบบนี้คะ ได้หรือยังคะ
***ลายเซ็นสูงเกินขนาด

dekjaidee

อ้างถึงจาก: CherryX ใน 21 กรกฎาคม 2018, 05:31:52
อ้างถึงจาก: maneemeena ใน 20 กรกฎาคม 2018, 10:15:11
ตอนผมหัด php ใหม่ๆ แล้วไล่หาบรรทัดเออเรอ ไม่เจอ ผมใช้วิธีการ

die("ผ่าน");

ไล่ทีละแถวเลยครับ  :wanwan020: :wanwan020: :wanwan020:

ต้องไล่ทีละแถวแบบนี้คะ ได้หรือยังคะ

งงจริงๆ ครับ

อ้างถึง
<?
require_once "connectdb.php";

$number="$_POST[number]";

$loop=strlen($number)-1;
for($i=0;$i<$loop;$i++)
{
$strs = substr($number,$i,2);

$sqlhr="select distinct numb,numtxt from horotest where numb='$strs'";
   $db_query=mysql_query($sqlhr);
    $reshr=mysql_fetch_array($db_query);
    $numbb = $reshr[numb];
   $numtxt = $reshr[numtxt];
   echo "$numbb<br>";

}
?>

INPUT ค่า  1111 เข้ามา มันก็ยังเป็น
11
11
11

แทนที่จะเป็น 11 แถวเดียวครับ

:P :P
HOW TO??