Help about selected row.. php HTML mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nemesisphp
Forum Newbie
Posts: 7
Joined: Thu Jul 08, 2010 11:41 pm

Help about selected row.. php HTML mysql

Post by nemesisphp »

Hello guys.. what i have here is the code of fetching the arrays of data in mySQL database..

i have this <a> tag here and i want to send the value of the specific selected row.. can you help me please?
here is my work

Code: Select all

<?php
			@require('connection.php');
			
			$query = "SELECT * FROM SUBJECTS WHERE CODE = '$code'";
			$result = mssql_query($query);
			$count = mssql_num_rows($result);
			
			while($row = mssql_fetch_array($result))
			{?>
					<li class="menu">
		<a class="noeffect" href="http://localhost/whereitgoes.php">
		<img src="../thumbs/mail.png"; /><span class="name"> 
		<?php 
			echo $row['CODE'];
			
		?>
        </span><span class="arrow"></span></a></li>
			<?php }?>
after i have loop the values..

how can i get the selected value? :)
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Help about selected row.. php HTML mysql

Post by liljester »

you can either do what you need to do with the values as they loop, or you can save them to an array for later use.
Thizzle
Forum Newbie
Posts: 12
Joined: Fri Jul 23, 2010 12:29 pm

Re: Help about selected row.. php HTML mysql

Post by Thizzle »

Try this:

Code: Select all

$row = mysql_fetch_array($result);
Where $row is the variable you want to store the row in...

to call on individual columns type : $row['columnname']
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Help about selected row.. php HTML mysql

Post by liljester »

thizzle, hes doing that in the code that he posted.
Thizzle
Forum Newbie
Posts: 12
Joined: Fri Jul 23, 2010 12:29 pm

Re: Help about selected row.. php HTML mysql

Post by Thizzle »

Oops sorry... Here.

Code: Select all

 
               <?php
                        include 'connection.php';
                        $query = ("SELECT code FROM SUBJECTS");
                        $result = mysql_query($query);
                        $row = mssql_fetch_array($result);
                        $code = $row['code'];
                        ?>
                                        <li class="menu">
                <a class="noeffect" href="http://localhost/whereitgoes.php">
                <img src="../thumbs/mail.png"; /><span class="name"> 
                <?php 
                        echo $code;
                        
                ?>
        </span><span class="arrow"></span></a></li>
nemesisphp
Forum Newbie
Posts: 7
Joined: Thu Jul 08, 2010 11:41 pm

Re: Help about selected row.. php HTML mysql

Post by nemesisphp »

There is a problem in your post thizzle..

The main problem is the loop.. on your code i can no longer see all the values(Loop) in my <li><a> tags

How can i manage them? thanks :)
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Help about selected row.. php HTML mysql

Post by liljester »

can you be more specific with what you want to do to the values? the loop that you posted looks correct, it should print out the code for each row. i guess i dont understande exactly what it is youre wanting to do with those values?
nemesisphp
Forum Newbie
Posts: 7
Joined: Thu Jul 08, 2010 11:41 pm

Re: Help about selected row.. php HTML mysql

Post by nemesisphp »

Code: Select all

<?php
                        @require('connection.php');
                        
                        $query = "SELECT * FROM SUBJECTS WHERE CODE = '$code'";
                        $result = mssql_query($query);
                        $count = mssql_num_rows($result);
                        
                        while($row = mssql_fetch_array($result))
                        {?>
                                        <li class="menu">
                <a class="noeffect" href="http://localhost/whereitgoes.php">
                <img src="../thumbs/mail.png"; /><span class="name"> 
                <?php 
                        echo $row['CODE'];
                        
                ?>
        </span><span class="arrow"></span></a></li>
                        <?php }?>
Sorry for the clarity of my problem..

i want to maintain the while { } in my code to display list according to what i have in my database..

The problem is .. how can i get the value of the selected list that is coming from the loop..


For more clarification

if i have 3 rows

row1
row2
row3

in thizzle's code.. i can only get row1..
so i need to use while in order to catch up with the overall results..

Now what i want is how to get the selected row.. if i select row3.. how can i manage to send the data having row3?
:)
nemesisphp
Forum Newbie
Posts: 7
Joined: Thu Jul 08, 2010 11:41 pm

Re: Help about selected row.. php HTML mysql

Post by nemesisphp »

Up
nemesisphp
Forum Newbie
Posts: 7
Joined: Thu Jul 08, 2010 11:41 pm

Re: Help about selected row.. php HTML mysql

Post by nemesisphp »

up
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Help about selected row.. php HTML mysql

Post by internet-solution »

nemesisphp wrote:
The problem is .. how can i get the value of the selected list that is coming from the loop..

......
Now what i want is how to get the selected row.. if i select row3.. how can i manage to send the data having row3?
:)
What do you mean by "selected list" or "selected row"? How are you selecting?
Post Reply