i need help..

Discussion in 'PHP' started by jagjeetsingh, Feb 25, 2010.

  1. #1
    hello friends
    im fetching data from table i want to show only one row data on page but its showing all data from the table.please could any body tell me query for that thank u.
    here is preview of my problem.
    [​IMG]
     
    jagjeetsingh, Feb 25, 2010 IP
  2. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #2
    can i see the code ?
     
    skywebsol, Feb 25, 2010 IP
  3. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php
    			
    		$slct=mysql_query("select * from mv" )or die(mysql_error());
    		while($ftch=mysql_fetch_array($slct))
    		{
    		?>
    
    <tr>
     <td>Code.</td>
    
     <td>
     <input  name='message' type="password"   value="Your verifation code is  <?=$ftch['cod'] ?>" " readonly="readonly">
    
     </td>
     </tr>
     <tr>
    
     <td width="200">Your  Mobile Number</td>
     <td>
     <input name='recipient' type='text' maxlength="10"  value="<?=$ftch['phn'] ?>" " readonly="readonly">
     </td>
     </tr>
    
    <?php
                }
             	 ?>
    PHP:
    i don't know how to make validation for this to show that only particular cod and number from db.
     
    jagjeetsingh, Feb 25, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    <?php
               
            $slct=mysql_query("select * from mv" )or die(mysql_error());
            $ftch=mysql_fetch_array($slct);
            {
            ?>
    
    <tr>
     <td>Code.</td>
    
     <td>
     <input  name='message' type="password"   value="Your verifation code is  <?=$ftch['cod'] ?>" " readonly="readonly">
    
     </td>
     </tr>
     <tr>
    
     <td width="200">Your  Mobile Number</td>
     <td>
     <input name='recipient' type='text' maxlength="10"  value="<?=$ftch['phn'] ?>" " readonly="readonly">
     </td>
     </tr>
    PHP:
    No need to loop, also consider using full php tags - it will be better in the long run.
     
    danx10, Feb 25, 2010 IP
  5. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    if you want to show only single data then do not use while loop only pass the primary key to mysql query

     
    skywebsol, Feb 25, 2010 IP
  6. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks friend its working.but still here one problem now phone no not showing in the field.
     
    jagjeetsingh, Feb 25, 2010 IP
  7. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #7
    i can help you again
     
    skywebsol, Feb 25, 2010 IP
  8. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    please do...
     
    jagjeetsingh, Feb 25, 2010 IP
  9. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #9
    code again pls i mean what you change
     
    skywebsol, Feb 25, 2010 IP
  10. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    <?php
    
    $slct=mysql_query("select * from mv where cod='$cod' AND phn='$phn'" )or die(mysql_error());
    $ftch=mysql_fetch_array($slct);
    ?>
    PHP:
    im using AND to fetch both values but its not working.only first value is showing.
     
    jagjeetsingh, Feb 25, 2010 IP
  11. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #11
    if code and phone no in same table

    id code phone no
    1 123 12345678

    then use only id where id= 1 or 2 or 3 like that
     
    skywebsol, Feb 25, 2010 IP
  12. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    code and phone both in same table but im not using id. cod is primary key
     
    jagjeetsingh, Feb 25, 2010 IP
  13. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #13
    if this not work tell how you fetcing $cod and $phn
     
    skywebsol, Feb 25, 2010 IP
  14. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    no dear its not working.here is the whole coding how im fetching the data.
    <?
    	session_start() or die ();
    ?>
    <?php
    	
    	include ("db_connect.php");
    ?>
    
    
    <?php
    
    $slct=mysql_query("select * from mv where cod='$cod' AND phn='$phn'" )or die(mysql_error());
    $ftch=mysql_fetch_array($slct);
    
    
    ?>
    
    
    <html>
    <script src="SpryValidationTextField.js" type="text/javascript"></script>
    <link href="SpryValidationTextField.css" rel="stylesheet" type="text/css">
    <script src="SpryValidationTextarea.js" type="text/javascript"></script>
    <link href="SpryValidationTextarea.css" rel="stylesheet" type="text/css">
    <title>Send Free Sms</title>
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="images/style.css" />
    <body>
    <div id="container">
    		<div id="header">
    Send Free Sms
    			</div>
    
     <h1></h1>
     <form method=post action='sendsmscodeforveri.php'>
     <table width="100%" border=0 cellpadding="5" cellspacing="5">
    
     <tr>
     <td>Code.</td>
    
     <td>
     <input  name='message' type="password"   value="Your verifation code is  <?=$ftch['cod'] ?>" readonly="readonly" " >
    
     </td>
     </tr>
     <tr>
    
     <td width="200">Your  Mobile Number</td>
     <td>
     <input name='recipient' type='text' maxlength="10"  value="<?=$ftch['phn'] ?>"  readonly="readonly"" >
     </td>
     </tr>
    
    
    
     <tr>
     <td> </td>
     <td><input type=submit name=submit value=Send></td>
    
     </tr>
     </table>
    
     </form>
     <script type="text/javascript">
    <!--
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "real", {validateOn:["blur", "change"], hint:"XXXXXXXXXX"});
    var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {maxChars:140, validateOn:["blur", "change"], counterType:"chars_remaining", counterId:"countsprytextarea1", hint:"enter your message here"});
    //-->
     </script>
    	</p>
    
    
     </body>
    
    </html>
    
    
    
    
    
    PHP:
     
    jagjeetsingh, Feb 25, 2010 IP
  15. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #15
    no no this is wrong code i mean where the value of $cod and $phn is coming from
     
    skywebsol, Feb 25, 2010 IP
  16. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    here is the code from that value coming.
    <?php
    include("db_connect.php");
    if(isset($_POST[submit]))
    {
    $a=$_POST[cod];
    
    $b=$_POST[phn];
    
    
    
    $insrt=mysql_query("insert into mv values(null, '$b')") or die(mysql_error());
    
    
    ?>
    
    <?php
                }
             	 ?>
    
    PHP:
     
    jagjeetsingh, Feb 25, 2010 IP
  17. jagjeetsingh

    jagjeetsingh Peon

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    no more replies?????????
     
    jagjeetsingh, Mar 1, 2010 IP
  18. skywebsol

    skywebsol Well-Known Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #18
    if you really need help i can work on your server, but you have to trust me. my gmail id is skywebsol@gmail.com
     
    skywebsol, Mar 1, 2010 IP