Jump to content

Getting Info from a From to another Form


JabsBlog

Recommended Posts

Ok here is my Issue .. I am creating a site where people can submit an entry. After the entry is submitted it is approved by an 'admin' .. once the admin approves the entry it is writen to a database in a table called approved. My index file .. shown below .. calls to the database and displays the enteries in dec order.

Each entry is assigned a unique ID. I have created a form that will allow the user to post a child to the Parent post.

My problem is getting the Unique ID from my index page .. to my new form on the next page.

I have included the unique blog_id in a hidden field in my index page. but once I click submit .. my action page. will not display the blog_id of the item that was submitted. .. It will display the first entry in the database.

Is there a way to grab the ID of the post and get that information to the new table on the next page.

Index.php
[code]<script language="JavaScript" type="text/javascript">
function submit ( selectedtype )
{
  document.childsubmit.submit() ;
}
</script>
</head>

<body>
<?php
include("db.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "SELECT * FROM approved ORDER by id DESC";

$result = mysql_query($query);

$num = mysql_numrows($result);

mysql_close();
?>
<div id="wrapper">
<div id="ad">
<a href="index.php"><img src="images/header.jpg" alt="BlogLink" border="0"/></a>
<br /><img src="images/addemo.jpg"/></div>

<div id="addto">
<ul id="navlist1">
<li>Get the feed:</li>
<li id="active1"><a href="http://feeds.my.aol.com/add.jsp?url=http%3A//www.bloglink.com/rss.xml" id="current1">MyAOL</a></li>
<li><a href="http://fusion.google.com/add?feedurl=http://www.bloglink.com/rss.xml">Google</a></li>
<li><a href="http://add.my.yahoo.com/rss?url=http://www.bloglink.com/rss.xml">Yahoo</a></li>
<li><a href="http://www.bloglines.com/sub/http://www.bloglink.com/rss.xml">Bloglines</a></li>
<li><a href="http://www.bloglink.com/rss.xml"><img src="images/xml.gif" alt="xml" border="0" /></a></li>
</ul>
</div>
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="submit.php" id="current">Submit Story</a></li>
<!-- When it's done <li><a href="categories.html">Categories</a></li> -->
<li><a href="faq.html">FAQ</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</div>
<div id="content">

<form action="myblog.php" method="post" name="childsubmit">
<?php $i=0;
while ($i < $num) {
$url = mysql_result($result,$i,"url");
$name = mysql_result($result,$i,"name");
$reason = mysql_result($result,$i,"reason");
$blog_id = mysql_result($result,$i,"blog_id");
$childpage = "$blog_id.php";
?>

<input type="hidden" value="<? echo $blog_id; ?>" name="child_id">
<input type="hidden" value="<? echo $name; ?>" name="title">


<div id="parent"><a href="<? echo $url; ?>"><? echo $name; ?></a></div>
<div id="snippet"><?php echo $reason; ?></div>
<a href="/articles/<? echo $childpage; ?>">See Who's Linking</a>
<a href="javascript:submit('submit')"><img src="images/link.gif" alt="submit your link" border="0" /></a>
<a href="aim:goim?message=<? echo $url; ?>"><img src="images/offline.gif" alt="IM this article" border="0" /></a><font size="2"></font>
<br /><br />
<?php $i++;
}
?>
</form>[/code]

mylog.php

The $child_id will only display the first entry of the database .. it will not grab the ID of the entry that was click on to submit a child.
[code]<?php

$title = $_POST['title'];
$child_id = $_POST['child_id'];

?>

<html>
<head>
<title>BlogLink :: Democratic Blogging</title>
<link rel="stylesheet" type="text/css" href="styles/index.css" />
</head>

<body>
<div id="wrapper">
<div id="ad">
<a href="index.php"><img src="images/header.jpg" alt="BlogLink" border="0"/></a>
<br /><img src="images/addemo.jpg"/></div>

<div id="addto">
<ul id="navlist1">
<li>Get the feed:</li>
<li id="active1"><a href="http://feeds.my.aol.com/add.jsp?url=http%3A//www.bloglink.com/rss.xml" id="current1">MyAOL</a></li>
<li><a href="http://fusion.google.com/add?feedurl=http://www.bloglink.com/rss.xml">Google</a></li>
<li><a href="http://add.my.yahoo.com/rss?url=http://www.bloglink.com/rss.xml">Yahoo</a></li>
<li><a href="http://www.bloglines.com/sub/http://www.bloglink.com/rss.xml">Bloglines</a></li>
<li><a href="http://www.bloglink.com/rss.xml"><img src="images/xml.gif" alt="xml" border="0" /></a></li>
</ul>
</div>
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="index.php">Home</a></li>
<!-- <li><a href="categories.html">Categories</a></li> -->
<li><a href="faq.html">FAQ</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</div>
<div id="content">
<div id="parent">
<h3>Submit your blog on this story</h3>
<strong>You are replying to: <? echo $title; ?></strong>
<form action="scripts/childAdd.php" method="post" name="childsubmit">
<table border="0" cellpadding="5">
<tr>
<td align="right"><strong>Article URL:</strong></td>
<td><input type="text" name="url" size="70" /></td>
</tr>
<tr>
<td align="right"><strong>Article Name:</strong></td>
<td><input type="text" name="name" size="70" /></td>
</tr>
<tr>
<td align="right"><strong>Summary:</strong></td>
<td><textarea name="reason" rows="3" cols="70"></textarea>
<text type"hidden" name="child_id" value="<? echo $child_id; ?>">
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Submit Article" /></td>
</tr>
</table>
</form>
</div>
<p class="copyright">Copyright 2006 &copy; BlogLink</p>
</div>
</body>

</html>
[/code]

to see what I am talking about .. goto .. http://test.imanass.com/BlogLink  .. view the page source.. you will see that the first post will have a blog ID of .. 1965080227 .. however when I click the link to add a post to that .. the value of the child ID becomes the first post .. 933281352.
So my question is how can I get it to get the ID of the item I am clicking on ?
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.