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

LVL 6
NeoAshuraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.