Jump to content

Insert Id Number Into Database


justlukeyou

Recommended Posts

Hi,

 

I can echo the id number of a member. "The ID Number is 239." I am now trying to enter number of the user as the organiserid.

 

I can insert eventname into the table but I am struggling to add the id number. Can anyone advise how I should be doing this please.

 

 

<div class="boardintro">
The ID Number is <?php echo (!empty($row['id'])) ? $row['id'] : ''; ?>
</div>

<?php
if(isset($_POST['createevent'])){
 $organiserid = trim($_POST['$id']);
$eventname = mysql_real_escape_string(trim($_POST['eventname']));

{
 $query = mysql_query("INSERT INTO table (eventname, organiserid) VALUES ('" .$eventname."', '" .$organiserid."')");
 if($query) {
 } else {
$error = "There was a problem with the submission. Please try again.";
 }
}
}
?>

Edited by justlukeyou
Link to comment
Share on other sites

Okay, so Im selecting it from the database and I can echo it. How do I allocate it to a variable.

 

So to transfer a variable from one table to another table I have to allocate it to a variable first?

 

 <?php
$query = "SELECT * FROM users WHERE id = " . intval($_SESSION['userID']) . " LIMIT 1";
if ($result = mysql_query($query)) {

		    $row = mysql_fetch_array($result);
}
		    ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.