homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

dynamic pages

 10:07 am on Apr 12, 2013 (gmt 0)

im new to using php, mysql and this website. i just could really do with some help on this, but as far as i know this code should be working...

mysql_select_db("test_art_center", $con);

$result = mysql_query("SELECT * FROM events");


$id = $event_data['EventID'] ;

echo "<a href=\"Edetails_page.php?id= '$id'>";
echo $event_data['description']." ".$event_data['UserID']." </a>";
echo "<br><br>";

i am trying to display all of the rows of the table as links to dynamic pages but it will only display one result and on the second page if i use

$id = $_GET['id'] ;

echo $id;

it shows the whole row and not just the event ID

i realise the code isn't going to be fantastic but if anyone could point out any way that i have gone wrong then please let me know



 11:35 am on Apr 12, 2013 (gmt 0)


Do not use the obsolete mysql interface anymore - esp. not for learning new things.
Use instead the mysqli (note the i) interface. ref: [php.net...]

Next, be very careful of security bugs.

$id = $_GET['id'] ;

echo $id;

is a XSS hole of epic proportions. Ref: [owasp.org...]
I'm unsure if you're aware of XSS: but one hole anywhere on your site has the potential to affect ALL you have on your entire domain.

As the your real question, it's a bit hard to see with the info you gave, but
echo "<a href=\"Edetails_page.php?id= '$id'>";

seems to have an spurious space after the equal sign that might be causing you grief.


 11:40 am on Apr 12, 2013 (gmt 0)

echo "<a href=\"Edetails_page.php?id= '$id'>";

Don't surround the URL parameter in single quotes and don't precede with a space. You also aren't closing the double quote of your href attribute, which is where all your extra data is coming. ie. It should be something like:
echo "<a href=\"Edetails_page.php?id=$id>\"";

Although I would choose to write this with single quotes and use string concatenation (so you don't need to escape the double quotes in your string):
echo '<a href="Edetails_page.php?id='.$id.'>"';

I would assume you are seeing the same jumble of data in the address bar?


 3:27 pm on Apr 12, 2013 (gmt 0)

thanks guys, yea I was getting the data in the address bar but this appears to have solved it and the link itself is working fine... the link is however not displaying the full data and is just showing a number... any ideas why this could be?


 4:03 pm on Apr 12, 2013 (gmt 0)

The link should be showing the contents of $event_data['description'] and $event_data['UserID'] - whatever they might contain. Have you verified that these fields are correct and populated? Use print_r() to get a snapshot of the array's contents.


 5:23 pm on Apr 12, 2013 (gmt 0)

ok i think its sorted, thanks penders

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved