I'm trying to pass an id in a link href and I need it to be printed in the URL, my code is:
echo " $ville_nom ";
But the id is not print in the url, could you help me with the syntax ?
You have mistake in your usage of echo and your concat was wrong.
The corrected code :
echo "<a href='ville.php?id='".$ville_id."'> $ville_nom ";
When you used the double quote it's not necessary to concat variables to show their content. Be careful: it can be dangerous sometimes.
echo "<a href='ville.php?id=$ville_id'> $ville_nom ";
Try to use this:
echo "<a href='ville.php?id=" . $ville_id . "'>"
Related
I would like to create a link within a while loop where the anchor link is a record from the query and the href passes a variable from the same query to another page so I only have to create one page that displays information based on the passed variable.
echo "<td>";
echo ''$row['result']''';
echo "</td></tr>";
This link kills my page and return an error.
echo "<td>";
echo ''.$row['result'].'';
echo "</td></tr>";
Should fix your code your quotes are not closed right
Your href string concatenation is incorrect.
It seems like you tried closing your strings and concatenating them halfway through and then stopped. Even with Stack Overflow you can see the string errors.
This is how your href echo should look:
echo '<a href="stats_game.php?idGame=' .$row['idGame'] . '>' . $row['result'] . '</a>';
It works fine for me
echo "<td><a href='stats_game.php?idGame=".$row['idGame']."'>".$row['result']."</a></td>";
I have this php line which works fine:
echo "<p>" . $post['message']. "</p>";
But I want to change it so it will link to my page (not to a single post). So it should look like that.
echo "<p>" . $post['message']. "</p>";
I have tried a lot many proposition gathered on different website, but each time I am getting an error.
Any idea ?
Thanks a lot!
Using single and double quotes, you avoid escaping issues. Try this:
echo '<p>'. $post['message']. '</p>';
i see that you didn't escaped from double quote that closes href attribute:
echo "<p><a href=\"https://www.facebook.com/rscmovement\" target=\"_blank\">"
I guess You have missed the back slash () before " after www.facebook.com/rscmovement.
"https://www.facebook.com/rscmovement\" "\"target=\"_blank\">" will
I want to pass name in get variable. That name contain spaces. So is not working in php.
$facid=$row['Facultyname'];
echo "<a href=tutorials.php?$facid>" . $row['Facultyname']. "</a><p>";
Please help me if Faculty name =A.K. Sharma then it only send A.K.
Encode the URL:
echo '<a href="tutorials.php?variable_name='.urlencode($row['Facultyname']).'">'
. $row['Facultyname']. '</a>';
EDIT:
Set a variable name for the GET.
Looks like you're not actually setting a variable after the ?, you're just pasting the value. Try:
$facid = $row['Facultyname'];
echo "<a href='tutorials.php?facid=". urlencode($facid) ."'>". $facid ."</a>";
I have following PHP echo statement:
echo "<td><a href='delete-news.php?deleteID=".$id." onclick='return confirm('Really delete?');'>Delete</a></td>";
which is convert to html as:
<td class="last-td nth-8"><a delete?');'="" confirm('really="" return="" href="delete-news.php?deleteID=5 onclick=">Delete</a></td>
As you can see something has gone wrong?
What is the problem? I have already tried swaping " " for single ' '.
Your have double single quotes in the onclick statement, try confirm(\'Really delete?\') instead.
You have forgot ' after href. Use it like
Double quotes:
echo "<td>Delete</td>";
Single quotes:
echo '<td>Delete</td>';
You have href not closed. Also, your 'Really delete' cause trouble too. Try this
echo "<td><a href='delete-news.php?deleteID=$id' onclick='return confirm(\"Really delete?\");'>Delete</a></td>";
There is a problem in this code I can not detected
<?php echo "<a href ='$rows['Link']'> .$rows['UploadName']</a> "; ?>
Do you find you have a solution???
Thank you very much.
My guess is that your problem is that it isn't writing out the data in $rows['Link'] ... if that is the case, then your solution is to change it to {$rows['Link']} ... actually, you'll probably want to change both, since it looks like you started doing string concatenation and then switched halfway through.
So:
<?php echo "<a href ='$rows['Link']'> .$rows['UploadName']</a> "; ?>
becomes:
<?php echo "<a href ='{$rows['Link']}'>{$rows['UploadName']}</a> "; ?>
See: The PHP Manual on Variable Parsing in strings
It should be:
<?php echo "<a href ='{$rows['Link']}'>{$rows['UploadName']}</a>"; ?>
Or:
<?php echo "<a href ='{$rows['Link']}'>" . $rows['UploadName'] . "</a>"; ?>
There's a problem in parsing variables in the string. Use curl braces:
<?php echo "<a href ='{$rows['Link']}'> .{$rows['UploadName']}</a> "; ?>
Take a look to this php.net page, under "variable parsing".
More alternatives:
<?php echo '' . $rows['UploadName'] . ''; ?>
or
<?=('' . $rows['UploadName'] . '')?>
Another alternative (that I tend to prefer, given I know that both 'Link' and 'UploadName' are valid indices of $row.
<?=$rows['UploadName']?>
I'm not sure what that does for readability for most people, but on color-coded IDEs, it tends to help, because the HTML isn't just seen as one giant ugly single-colored string.