• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

PHP MYSQL Output data

The page does not work correctly it does not show my table with my data required from my database.

Could someone please help me fix these issues.

I thank you for your time

code is attached.

Also please see in my query where im getting * from customer.

when i dump my $result var it just shows resource id rather than the data.

What im trying to achieve as you can problery see is a form with the current data for the customer from the database. if ive done any bits wrong please can you also advise.
<?php 
error_reporting(E_ALL);
include 'myphp.php';
$val = $_GET['val'];

$sql = " SELECT * FROM customer WHERE customer_name='" .$val. "'";
$result = mysql_query($sql) or die(mysql_error() . " IN $sql");
$result=mysql_query($sql);
$num=mysql_fetch_row($result);
var_dump($result);
var_dump($sql);
var_dump ($val);



 $i=0;
while ($i < $num) {
$customer_name=mysql_result($result,$i,"customer_name");
$title=mysql_result($result,$i,"title");
$first_name=mysql_result($result,$i,"first_name");
$last_name=mysql_result($result,$i,"last_name");
$account_number=mysql_result($result,$i,"account_number");
$dealer=mysql_result($result,$i,"dealer");
$staff=mysql_result($result,$i,"staff");
$full_address=mysql_result($result,$i,"full_address");
$telephone_number=mysql_result($result,$i,"telephone_number");
$contact_name=mysql_result($result,$i,"contact_name");
$fax=mysql_result($result,$i,"fax");
$contact_mobile=mysql_result($result,$i,"contact_mobile");
$network=mysql_result($result,$i,"network");
$kit_fund_level=mysql_result($result,$i,"kit_fund_level");
$email=mysql_result($result,$i,"email");
$staff_member=mysql_result($result,$i,"staff_member");

?>
<form action="updated.php" method="post">
Customer Name:<input type="text" name="customer_name" value="<? echo $customer_name; ?>"><br>
Title: <input type="text" name="title" value="<? echo $title; ?>"><br>
First Name: <input type="text" name="first_name" value="<? echo $first_name; ?>"><br>
Last Name: <input type="text" name="last_name" value="<? echo $last_name; ?>"><br>
Account Number: <input type="text" name="account_number" value="<? echo $account_number; ?>"><br>
Dealer: <input type="text" name="dealer" value="<? echo $dealer; ?>"><br>
staff: <input type="text" name="staff" value="<? echo $staff; ?>"><br>
Full Address<textarea name="full_address" rows="10" cols="35"><?php echo $full_address;?></textarea>
Telephone Number: <input type="text" name="telephone_number" value="<? echo $telephone_number; ?>"><br>
Contact Name: <input type="text" name="contact_name" value="<? echo $contact_name; ?>"><br>
Fax: <input type="text" name="fax" value="<? echo $fax; ?>"><br>
Contact Mobile: <input type="text" name="contact_mobile" value="<? echo $contact_mobile; ?>"><br>
Network: <input type="text" name="network" value="<? echo $network; ?>"><br>
Kit Fund: <input type="text" name="kit_fund_level" value="<? echo $kit_fund_level; ?>"><br>
Email: <input type="text" name="email" value="<? echo $email; ?>"><br>
Staff Member: <input type="text" name="staff_member" value="<? echo $staff_member; ?>"><br>
<input type="Submit" value="Update">
</form>
<?php
++$i;
}
   ?>

Open in new window

0
NeoAshura
Asked:
NeoAshura
  • 3
  • 2
1 Solution
 
Pratima PharandeCommented:
try something like this
change code like this

 <?php
error_reporting(E_ALL);
include 'myphp.php';
$val = $_GET['val'];

$sql = " SELECT * FROM customer WHERE customer_name='" .$val. "'";
$result = mysql_query($sql) or die(mysql_error() . " IN $sql");
$result=mysql_query($sql);

while($row=mysql_fetch_array($result))
{
$customer_name= $row['customer_name'];
$title=$row['title'];  
$first_name=$row['first_name'];  
$last_name=$row['last_name'];
$account_number=$row['account_number'];
$dealer=$row['dealer'];
 
}
0
 
NeoAshuraAuthor Commented:
thanks for the quick reply,

the table now shoes but the boxes have <?php echo $title;?> in them when it should be for example "Mrs" any ideas??

New code is attached.


<?php 
error_reporting(E_ALL);
include 'myphp.php';
$val = $_GET['val'];

$sql = " SELECT * FROM customer WHERE customer_name='" .$val. "'";
$result = mysql_query($sql) or die(mysql_error() . " IN $sql");
$result=mysql_query($sql);


var_dump($result);
var_dump($sql);
var_dump ($val);



while($row=mysql_fetch_array($result))
{
$customer_name= $row['customer_name'];
$title=$row['title'];  
$first_name=$row['first_name'];  
$last_name=$row['last_name'];
$account_number=$row['account_number'];
$dealer=$row['dealer'];
$staff=$row['staff'];
$full_address=$row['full_address'];
$telephone_number=$row['telephone_number'];
$contact_name=$row['contact_name'];
$fax=$row['fax'];
$contact_mobile=$row['contact_mobile'];
$network=$row['network'];
$kit_fund_level=$row['kit_fund_level'];
$enail=$row['email'];
$staff_member=$row['staff_member'];

?>
<form action="updated.php" method="post">
Customer Name:<input type="text" name="customer_name" value="<? echo $customer_name; ?>"><br>
Title: <input type="text" name="title" value="<? echo $title; ?>"><br>
First Name: <input type="text" name="first_name" value="<? echo $first_name; ?>"><br>
Last Name: <input type="text" name="last_name" value="<? echo $last_name; ?>"><br>
Account Number: <input type="text" name="account_number" value="<? echo $account_number; ?>"><br>
Dealer: <input type="text" name="dealer" value="<? echo $dealer; ?>"><br>
staff: <input type="text" name="staff" value="<? echo $staff; ?>"><br>
Full Address<textarea name="full_address" rows="10" cols="35"><?php echo $full_address;?></textarea><br><br>
Telephone Number: <input type="text" name="telephone_number" value="<? echo $telephone_number; ?>"><br><br />
Contact Name: <input type="text" name="contact_name" value="<? echo $contact_name; ?>"><br>
Fax: <input type="text" name="fax" value="<? echo $fax; ?>"><br>
Contact Mobile: <input type="text" name="contact_mobile" value="<? echo $contact_mobile; ?>"><br>
Network: <input type="text" name="network" value="<? echo $network; ?>"><br>
Kit Fund: <input type="text" name="kit_fund_level" value="<? echo $kit_fund_level; ?>"><br>
Email: <input type="text" name="email" value="<? echo $email; ?>"><br>
Staff Member: <input type="text" name="staff_member" value="<? echo $staff_member; ?>"><br>
<input type="Submit" value="Update">
</form>
<?php
++$i;
}
   ?>

Open in new window

0
 
Pratima PharandeCommented:
are you saying you are not getting values in textbox ???


 <input type="text" name="title" value="<? echo $title; ?>">

Try like this

 <input type="text" name="title" value=<?Php echo $title; ?>>
or

 <input type="text" name="title" value='<? echo $title; ?>'>
0
 
NeoAshuraAuthor Commented:
that worked a charm thanks forgot i had short tags turned off.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now