0

I am stuck, my code should manage contacts and be able to alter them.

I would like to click to the Name1, Name2, Name3 and be able to see on the right hand side and be able to submit/save it in my SQL DB.

<?php 
include("db_con1.php"); 

// left side people list
$peoplelist='SELECT contact_first, contact_sur, contact_mobil FROM contactmain WHERE status=1';
$queryl = $pdo->prepare($peoplelist);
$queryl->execute();
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>
  <title>Email sending program</title>
  <link rel="stylesheet" type="text/css" href="css/adminolok.css">
  <link rel="stylesheet" type="text/css" href="css/menu.css">

  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
  <script>
  $('leftnavigation a.names').click(
    var thisId = $(this).attr('id');
    $('.midtop input').val( $(this).html() + $(this).attr('id'); );
  </script>
</head>

<body>
<?php include("menu.php"); ?>

<div id="leftnavigation">
<ul>
<?php foreach ($queryl as $i => $rowl) { ?>
<li >
  <a href="#" class="names" id="<?php echo $i; ?>">
    <span class="name">
     <?php echo $rowl['contact_first'].' <strong>'.$rowl['contact_sur'].'</strong>'; ?>
    </span>
    <br />
    <span class="mobil"><?php echo $rowl['contact_mobil'];?></span>
  </a>
<?php  }?>
</li>
</ul>
</div>


<div id="midtop">
 Change your name: <input type="text" name="name" />

</div>

</body>
</html>

As I am getting more and more help I feel that I will be... but it is still full of bug as it doesn't work yet. Any help would be really appreciated.

Made some alteration as I've been taught to do so:)))) thanks for that

5
  • Your question does not make sense. What do you mean by, I am stack with my code to pass the info from left to right. What does this have to do with mySQL? Commented Sep 1, 2011 at 16:51
  • sorry for my English hope this version make more sense:) Commented Sep 1, 2011 at 16:56
  • 1
    You should replace $('.midtop input').val( $(this).html() with $(this).attr('id'); ); with $('.midtop input').val( $(this).html() + $(this).attr('id'); ); Commented Sep 1, 2011 at 20:39
  • @madc: thanks for your kind help. I keep trying but it still doesn't give any result yet. Any other though? Commented Sep 1, 2011 at 20:54
  • Jip. Try changing leftnavigation to #leftnavigation Commented Sep 3, 2011 at 18:54

2 Answers 2

1

I think you need something like this:

$('label').click(function(){
  $('.right input').val( $(this).html(); );
});
Sign up to request clarification or add additional context in comments.

4 Comments

thanks for helping. So where do I need to insert this in the code?
I have changed the label's attributes now each label individual how could I pass the info to the <input>. Sorry for asking to much but I would like to learn it:)
And, yeah, it yould replace your ???. To get the value of the for-attribute, i would say, you have to repace $(this).html() with $(this).attr('for').
am I getting closer to the solution? (unfortunately still doesn't work yet)
0

You can align your list horizontally using CSS:

ul li {
  display: inline-block;
}

Check the Live Demo

1 Comment

thanks very much for your answer. I have 3000 names in my contact list, so I would stay vertical, but it is a good hint!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.