argonz Posted November 13, 2010 Share Posted November 13, 2010 e.g table : categoryfile :category_idcategory_nmand I have menu.php $query1 = "select * from category";$query2 = mysql_query($query1);while($query3 = mysql_fetch_array($query2)){<a href=index.php?page=view.php>$query3[nm_category]</a><br />// another script} for example, there are 3 record in category. computer, law, medicali need variable in view.php from menu.php to identify which data will show in view.php according to category !how do it can be done ? Link to comment Share on other sites More sharing options...
birbal Posted November 13, 2010 Share Posted November 13, 2010 i am not sure what you want to do.if you want to send data(variable) to other page you can do like this. echo "<a href='view.php?catid={$query3['category_id']}'>{$query3['category_nm']}</a>"; you can catch the data in view.php by using $_GET in the view.php page.there are some problems in the code. you should use echo to display anything. and you have to use {} for associative arrays when you use it in double quotes.there single quotes are missing in associative array $query3[nm_category] should be $query3['nm_category']single quote is missing in <a href='....> tag also.category_nm is your table column name should be same $query3['category_nm'] when you fetching data from database.you use $qry1,$qry2,$qry3. you may want to use some descriptive name for variable. so it will be very eased to understand the purpose of the variable. though here the purpose of the $qry1-$qry3 is not same. though it is not an issue but it will increase the ease of reading and understanding. Link to comment Share on other sites More sharing options...
argonz Posted November 14, 2010 Author Share Posted November 14, 2010 oh sorry, I forgot to write echo.., I need "index.php?page=view.php" to include view.php in index.php. but, about the problem, I've got the solution. I put "&" and write variable again, like this : echo "<a href='index.php?page=view.php&catid=$query3[category_id]'>$query3['category_nm']</a>"; in the past, i don't know how to use 2 variable or more in url. but with & its done.thank you for asking me to use {}, single quote.., even it work fine for me. but I've read that its required to completely cross-platform compatible.., isn't it ? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.