-
looping in the table
Code:
<html>
<head><title>Your Page Title</title></head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'hello';
$dbname = 'user';
echo "hello";
// make a connection to mysql here
$conn = mysql_connect ($dbhost, $dbuser, $dbpass);
if(!$conn)
{
die('could not connect: ' . mysql_error());
}
else
echo "<BR>connected";
//select database to use
$conn = mysql_select_db ($dbname);
echo "<BR>connected to db" ;
$result = mysql_query("SELECT taxtype.taxtypeid,taxname,group_concat(formno),actid,taxtype.status as formnum FROM taxtype,taxform where taxtype.taxtypeid=taxform.taxtypeid group by taxtypeid")or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "<BR>" . $num_rows;
print "<table width=500 border=1>\n";
while($row = mysql_fetch_row($result))
{
print "<tr>\n";
print "\t<td><font face=arial size=1/>$row[0]</font></td>\n";
print "\t<td><font face=arial size=1/>$row[1]</font></td>\n";
print "\t<td><font face=arial size=1/> <a href=\"http://localhost/.php\" target=\"_blank\">$row[2]</a> </font></td>\n";
print "\t<td><font face=arial size=1/>$row[3]</font></td>\n";
print "\t<td><font face=arial size=1/>$row[4]</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
</body>
</html>
with this code i get an output(in the form of a table)
Code:
1 mst 786 32543655768 true
2 pst 567 435604280349 true
3 tat 345,56 463139621081 true
4 wat form 12,form 24,form 14 32649342018 true
but then i want to have separate hyperlinks for the strings in the 2nd cell of each row i.e and i want them all in one cell only
Code:
1 mst 786 32543655768 true
2 pst 567 435604280349 true
3 tat 345,56 463139621081 true
4 wat form 12,form 24,form 14 32649342018 true
So .plz could someone help me wid this ...extremely urgent
-
Do the links go to separate URLs? If so, how are they defined?
All you need to do if the links point to the same place is split the text, link the pieces, and put them back together. Separate URLs will probably involve str_replace.
-
well..yes all the links would be point to the same url..
and i have been trying to do the same way as u have told me too.
Code:
$result = mysql_query("SELECT taxtype.taxtypeid,taxname,group_concat(formno),actid,taxtype.status as formnum FROM taxtype,taxform where taxtype.taxtypeid=taxform.taxtypeid group by taxtypeid")or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "<BR>" . $num_rows;
print "<table width=500 border=1>\n";
while($row = mysql_fetch_row($result))
{
print "<tr>\n";
print "\t<td><font face=arial size=1/>$row[0]</font></td>\n";
print "\t<td><font face=arial size=1/>$row[1]</font></td>\n";
$forms=explode(",",$row[2]);
$size= count($forms);
echo "<BR>" . $size;
for ($i=0;$i<$size;$i++)
{
print "\t<td><font face=arial size=1/> <a href=\"http://localhost/.php\" target=\"_blank\">$forms[$i]</a> </font></td>\n";
}
print "\t<td><font face=arial size=1/>$row[3]</font></td>\n";
print "\t<td><font face=arial size=1/>$row[4]</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
when i do this way i get an output(in the form of a table)i.e all of them displayed in different cells
Code:
1 mst 786 32543655768 true
2 pst 567 435604280349 true
3 tat 345 56 463139621081 true
4 wat form 12 form 24 form 14 32649342018 true
and please could also tell whther thr is any other way to split the text,and how to again combine them ?
-
if the problem is only that its writting multiple cells try this
Code:
print "\t<td>";
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=1/> <a href=\"http://localhost/.php\" target=\"_blank\">$forms[$i]</a> </font>\n";
}
print "</td>";
-
Why do you want another way to split the text? Anyway, see the See Also section here.
As for putting the pieces back together, you've shown that to be unnecessary. I was thinking of how to build a function to call for this, outputting the same kind of value as was input. Printing the data directly removes this need.
-
thank u a lot bluewalrus and jedisciple ,it am geting the output in the required form
noe my o/p is
Code:
1 mst 786 32543655768 true
2 pst 567 435604280349 true
3 tat 345 56 463139621081 true
4 wat form 12 form 24 form 14 3649342018 true
but how to i separate them with commas,like in the 3rd row ,3rd cell..i would like to have
one way i know is using implode ,but i m not knowing how to use it in the hyperlink tag while printing
-
You can just put it in after the link like this I think no need for implode.
PHP Code:
print "\t<td>";
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=1/> <a href=\"http://localhost/.php\" target=\"_blank\">$forms[$i]</a>, </font>\n";
}
print "</td>";
-
If you don't want a comma after the last link...
PHP Code:
for($i = 0; $i < count($forms); $i++)
$forms[$i] = "<font face=arial size=1/><a href=\"http://localhost/.php\" target=\"_blank\">$forms[$i]</a></font>";
echo "\t" . implode(', ', $forms) . "\n";
-
well ,i would like to have a little more help from u ..
Code:
print "\t<td>";
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=1/> <a href=\"http://localhost/.php\" target=\"_blank\">$forms[$i]</a>, </font>\n";
}
print "</td>";
in this code when i click on one of the form no , it would direct me to another php page ,where i would like to retrive the value of the form number so that i can display the value.
for example
Code:
1 mst 786 32543655768 true
2 pst 567 435604280349 true
3 tat 345 56 463139621081 true
4 wat form 12 form 24 form 14 3649342018 true
So here if i click on any of the forms say 567,then when it redircts me to the another page i want to automatically display the value 567 in the next step.
like
Code:
FORM no: 567
NAME:.
ADDRESS:
....
so plz could you help me doing this.
-
Should links on lines with multiple links display different information when clicked?
Either way, when you wrap the form's name in a link, change the target of the link to include a GET value. To put different forms behind different links, it could be .php?form=$form[$i].
-
when we click any form it will direct to the same page..(say form.php, hich i forgot to mention)
Code:
<html>
<head><title>Your Page Title</title></head>
<body>
<?php
session_start();
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'sister';
$dbname = 'login';
echo "hello";
// make a connection to mysql here
$conn = mysql_connect ($dbhost, $dbuser, $dbpass);
if(!$conn)
{
die('could not connect: ' . mysql_error());
}
else
echo "<BR>connected";
//select database to use
$conn = mysql_select_db ($dbname);
echo "<BR>connected to db" ;
$result = mysql_query("SELECT taxtype.taxtypeid,taxname,taxdesc,group_concat(formno),group_concat(formno2),actid,taxtype.status as formnum FROM taxtype,taxform where taxtype.taxtypeid=taxform.taxtypeid group by taxtypeid")or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "<BR>" . $num_rows;
print "<table width=500 border=1>\n";
print "<tr>\n";
print "\t<td><font face=arial size=4/>S.No.</font></td>\n";
print "\t<td><font face=arial size=4/>Tax Name</font></td\n";
print "\t<td><font face=arial size=4/>Tax Description</font></td\n";
print "\t<td><font face=arial size=4/>Return-cum-challan(TIN/RC No. mandatory):</font></td\n";
print "\t<td><font face=arial size=4/>Challan No (TIN/RC No. not mandatory):</font></td\n";
print "\t<td><font face=arial size=4/>Act ID:</font></td\n";
print "\t<td><font face=arial size=4/>Status</font></td\n";
print "</tr>\n";
while($row = mysql_fetch_row($result))
{
//echo "<BR>" . $row[0] . " " . $row[1] . " " . $row[2] ;
print "<tr>\n";
print "\t<td><font face=arial size=2/>$row[0]</font></td>\n";
print "\t<td><font face=arial size=2/>$row[1]</font></td>\n";
print "\t<td><font face=arial size=2/>$row[2]</font></td>\n";
$forms=explode(",",$row[3]);
$size= count($forms);
echo "<BR>" . $size;
print "\t<td>";
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=2/> <a href=\"http://localhost/form.php\" target=\"_blank\">$forms[$i]</a> </font>\n";
}
print "</td>";
$forms1=explode(",",$row[4]);
$size= count($forms1);
echo "<BR>" . $size;
print "\t<td>";
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=2/> <a href=\"http://localhost/.php\" target=\"_blank\">$forms1[$i]</a> </font>\n";
}
print "</td>";
print "\t<td><font face=arial size=2/>$row[5]</font></td>\n";
print "\t<td><font face=arial size=2/>$row[6]</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
ADD A NEW TAX
<a href="http://localhost/newtax.php" target="_blank">NEW TAX</a>
</body>
</html>
now,what i want is..when i click on any of the links(which would direct me to same page login.php) ,i want to display the value in the link on the new page i.e on form.php....as i mentioned in my previous post
i tried using session variable in the page where the above code is present ..
but how do i store the value of the link i have clicked ..?
and moreover i didnt understnd the wrapping concept which u have suggested.
-
I have a little problem , i have a table in my database called "typetax" in which one of the column is "taxname" which consist of names of different taxes.
now i want to connect to the database using php(which i know how to do) and then i would like to diaplay all the taxes using a drop down list.
i am getting confused how to use html and php together ..
Code:
<html>
<head>
<title>DATAENTRER PAGE</title>
</head>
<body>
<?php
session_start();
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'sister';
$dbname = 'login';
echo "hello";
// make a connection to mysql here
$conn = mysql_connect ($dbhost, $dbuser, $dbpass);
if(!$conn)
{
die('could not connect: ' . mysql_error());
}
else
echo "<BR>connected";
//select database to use
$conn = mysql_select_db ($dbname);
echo "<BR>connected to db" ;
$result = mysql_query("SELECT taxname FROM taxtype")or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "<BR>" . $num_rows;
?>
</body>
</html>
but now how do i display all the taxname's on the page in a drop down format using php?
its really urgent so please could u help me in this
-
Would you please not make your entire messages bold anymore? It's senseless, and kind of annoying.
The session veriable is probably not the best way. To get the link's value into the session, you'd need JavaScript, but that would be obtrusive which is bad. (obtrusive = inaccessible to the user without JS available or enabled.)
I was suggesting that each link have the name of the form in a GET variable - and that's just a second use of the form's name that we already have. So...
Code:
print "\t<td>";
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=1/> <a href=\"http://localhost/form.php?form=$forms[$i]\" target=\"_blank\">$forms[$i]</a>, </font>\n";
}
print "</td>";
For your last post, use a while($row = mysql_fetch_array($result)) loop inside of a select element. I recently did something similar in this script. In my case, the while loop isn't actually in the select but the same idea is used.
-
How can i print the "link text" of a hyperlink in html in the next page (to which its it directed to)
for eg:
<a href="http://localhost/form.php" target="_blank">566</a>
when i click the link 566 ..i will be directed to form.php.Now i would like to display the number 566 (i.e by passing it from prev page to this page)
-
well sir, i m sorry that u have alrdy given me the solution for this , but i have another doubt here , how do i separate two values if i need to pass more than one value
Code:
for ($i=0;$i<$size;$i++)
{
print "\t<font face=arial size=2/> <a href=\"http://localhost/form.php?tname=$row[1] ,form=$forms[$i]\" target=\"_blank\">$forms[$i]</a> </font>\n";
}
print "</td>";
by using a comma ,isnt helping me ..so plz could u tell me how to go about it
-
To access your values, use $_GET['form'] and $_GET['tname']. I prefer to rename them to something more readable and typable, like $form and $tname. However, to use a new name to validate that a value was actually passed you must assign by reference:
Code:
$form =& $_GET['form'];
if(isset($form)){
...
}
The separator for GET annd POST values is the ampersand (&). If you ever write a cookie (small data file that the browser stores on the user's computer), you'll need to use a semicolon (;) instead. EDIT: And don't include any spaces around either separator.