Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

I was trying to pull the names and the date form the same user fileld

Recommended Posts

This comes from the database and pulls the names correctly.
[code]
echo"<OPTION VALUE='".$record["name"]."'>".$record["name"];
[/code]

I was trying to pull the names and the date from the same user fileld to show name and date from pull down together.

example but wrong can you help cheers.
[code]
echo"<OPTION VALUE='".$record["name"]."' '".$record["date"]."'>".$record["name"] $record["date"];
[/code]

Advance thank you.

Share this post


Link to post
Share on other sites
And what happens or doesn't happen when you use that code?

Share this post


Link to post
Share on other sites


Keep getting a phase errow on that line.

[code]

Parse error: parse error, expecting `','' or `';'' in C:\Program Files\Apache Group\Apache2\htdocs\collage\project\search.php on line 17

[code]

Share this post


Link to post
Share on other sites
you need to get rid of the single quotes. should be
[code]echo"<OPTION VALUE='".$record["name"]." ".$record["date"]."'>$record['name'] $record['date']</OPTION>";[/code]

Ray

Share this post


Link to post
Share on other sites
[!--quoteo(post=365989:date=Apr 18 2006, 01:23 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Apr 18 2006, 01:23 PM) [snapback]365989[/snapback][/div][div class=\'quotemain\'][!--quotec--]
you need to get rid of the single quotes. should be
[code]echo"<OPTION VALUE='".$record["name"]." ".$record["date"]."'>$record['name'] $record['date']</OPTION>";[/code]

Ray
[/quote]
[code]
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\Program Files\Apache Group\Apache2\htdocs\collage\project\search.php on line 17
[/code]

still wrong sorry

Share this post


Link to post
Share on other sites
[code]echo "<OPTION VALUE='". $record["name"]. " ". $record["date"]. "'>". $record['name'] $record['date']. "</OPTION>";[/code]

Share this post


Link to post
Share on other sites
Ya i see i tested my code out with just some variables above. This worked for me

[code]echo"<OPTION VALUE='".$record['name']." ".$record['date']."'>".$record['name']." ".$record['date']."</OPTION>";[/code]

Ray

Share this post


Link to post
Share on other sites
Test it with a database to get name and date on the same pull down menu dosent work agree varables without database works.


The full code test it on a database dosent work but name on it's own does.
[code]
<html>
<head>
<title>search2</title>
<body>
search me via search box
<form  method="post" action="search_result.php">
<SELECT NAME="name">
<?
$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("schollwork", $db);
$query="select * from feedback";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){
echo "<OPTION VALUE='". $record["name"]. " ". $record["date"]. "'>". $record['name']
$record['date'].;
}

?>
</select>
<input type="submit" value="submit">
</form>
</body>
</html>
[/code]

Share this post


Link to post
Share on other sites
[code]echo "<OPTION VALUE='". $record["name"]. $record["date"]. "'>". $record['name']. "". $record['date']. "</OPTION>";[/code]
That works. You might want to separate the name and date with | to make it easier to split them later.

[code]echo "<OPTION VALUE='". $record["name"]. $record["date"]. "'>". $record['name']. "|". $record['date']. "</OPTION>";[/code]

Share this post


Link to post
Share on other sites

Thank you andy in the end all i needed to see the date and not get the script to search via name and date cheers thanks so much.

[code]
<html>
<head>
<title>search2</title>
<body>
search me via search box
<form  method="post" action="search_result.php">
<SELECT NAME="name">
<?
$db=mysql_connect("localhost","xxxx","xxxx");
mysql_select_db("schollwork", $db);
$query="select * from feedback";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){

echo "<OPTION VALUE='". $record["name"]."'>". $record['name']. "  ". $record['date'].

"</OPTION>";
}

?>
<input type="submit" value="submit">
</form>
</body>
</html>
[/code]

[!--sizeo:6--][span style=\"font-size:24pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]

Share this post


Link to post
Share on other sites

×

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.