Jump to content

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


redarrow

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.
Link to comment
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
Link to comment
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
Link to comment
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]
Link to comment
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]
Link to comment
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--]
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.