Jump to content

Get values from database into table from value passed to it


vandero

Recommended Posts

I need to get the value passed from another table.  That is working as far as the URL:

 

Teams.php?name=April

 

 

<?php

include('connect_php');

$result = $db->prepare("SELECT * FROM Teams ORDER BY Dateenrolled WHERE Teamname ="".$_GET["name"]."");

$result->execute();

for($I=0;$row=$result->fetch(); $I++)

{

?>

<tr>

<td width="7%"><?php echo $row['Paid'];?></td>

<td width="10%"><?php echo $row'Teamname']; ?></td>

</tr>

<?php

}

?>

 

It shows my table but the error messages are 5 sentences long and include uncaught errors, lots of syntax errors and such.  I can type them if needed.  My PHP programming class was 12 years ago.

 

Doesn't pull any data in to the table.

 

Any help or suggestions would be great.  Worked on this now for over a week off an on with nothing more than changing error messages.

 

 

 

Link to comment
Share on other sites

you would start with the first error message, read it, determine what it means, then find what about your code is causing it.

 

btw - one of the points of using a prepared query is that you don't put data values directly into the query, but you put a place-holder into the query and bind the variable/value to that place-holder.

Link to comment
Share on other sites

I think I know what you mean by binding the variable.  I had the values from the _GET part assigned to a variable earlier, but got rid of that thinking that was causing some of the problems.  I will start with the first error, my frustration with that was the error messages would change but I couldn't be sure if I had revealed another issue that was hidden, or if I just had replaced one error with another error.  This just can't be as complicated as I am making it out to be.  Thanks.

Link to comment
Share on other sites

This just can't be as complicated as I am making it out to be.

 

it's not. most programming languages are simple compared to any linguistic language, and are far more constant and intuitively obvious (they have to be if a computer can parse the code and run it.) there are far fewer syntax/spelling rules that must be learned.

 

however, we constantly see people that use the 'random trial' approach to programming. they keep trying different things they have seen or found without any idea what they mean or if they even contribute anything to the goal they are trying to accomplish.

 

when code doesn't work, you must find out why and fix it, otherwise you are just wildly spinning your wheels wasting time that doesn't do anything toward accomplishing your goal. and while some computer generated error messages could be better, most, within the context of where they where detected, do provide information that points to the cause of the error.

Link to comment
Share on other sites

Well you described my approach to this.  I think in some cases this happens because of time constraints.  Hey we need a website up and running in a few weeks, can you do that and work your two jobs, etc.  So a good hearted person says I'll try and help you out.  I need to learn about prepare, _GET and execute.  Then this will be a piece of cake.  Last step of the website too.

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.