Page 1 of 2
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 25 Oct 2016, 12:27
by melmdoost
thank you for your free code.
i use
https://coursesweb.net/php-mysql/filter- ... t-lists_s2 from your site.
it was very good and applicable. but i want final result (output) show (echo) in a table for each column.
how can i do it?
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 25 Oct 2016, 13:41
by Admin
Hello
Final result is the description? What data you want in a table?
I do not understand what you want.
Did you try something?
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 25 Oct 2016, 15:18
by melmdoost
hello,
Suppose, for example, output for the machine name, color and model. I want this to be displayed in a table.
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 25 Oct 2016, 16:10
by Admin
I not know what output you refer, the script generates output with values for <option>s in <select> list, and for description.
If you want to modify the html for description to add it in a table, edit /set html elements in this part of code, in "msla2.php" file:
Code: Select all
//sets data in 'descr', each row with all columns for description is added in <div>, each description in <span>
if($cols[0] !=$col && $nrc >0 && in_array($cols[$col_i], $sel_desc)){
for($i=0; $i<$nrc; $i++){
$re_msla2['descr'] .='<span>'. $row[$col_desc[$i]] .'</span>';
}
$re_msla2['descr'] ='<div class="msla2_descr">'. $re_msla2['descr'] .'</div>';
}
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 31 Oct 2016, 10:24
by melmdoost
hello,
How can I have a link for each of query in this instance? i mean <a href>.
i mean "coursesweb.net/php-mysql/filter-multiple-select-lists_s2"
i have two questions:
1. How can I have a link for each of query in this instance? i mean <a href>.
2. suppose, result of query look like this:
uupload.ir/files/gmcx_2016-10-31_13-42-00.jpg
how can i have query look like this:
uupload.ir/files/j2f7_2016-10-31_13-42-29.jpg
thanks
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 31 Oct 2016, 14:50
by Admin
If you want to modify the html code for the final result, change /edit this line of code, in "msla2.php".
Code: Select all
$re_msla2['descr'] .='<span>'. $row[$col_desc[$i]] .'</span>';
For example:
1. to add results in <a>:
Code: Select all
$re_msla2['descr'] .='<span><a href="'. $row[$col_desc[$i]] .'" title="link-text">'. $row[$col_desc[$i]] .'</a></span>';
2. Or, for second question:
Code: Select all
$re_msla2['descr'] .='<span>http://'. str_ireplace(['://', '/', ':::'], [':::', '--------', '://'], $row[$col_desc[$i]]) .'</span>';
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 07 Nov 2016, 20:46
by melmdoost
Hello, thank you for your response.
i have another question.
i want change this script:
Code: Select all
$re_msla2['descr'] .='<span><a href="'. $row[$col_desc[$i]] .'" title="link-text">'. $row[$col_desc[$i]] .'</a></span>';
with this script:
Code: Select all
$re_msla2['descr'] .='<span><a href=" search.php?id='$rows[id]' " title="link-text">'. $row[$col_desc[$i]] .'</a></span>';
but it have an error.
it does not work correctly. i do not why!
do you know?
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 08 Nov 2016, 06:34
by Admin
Well, try this code (see yourself the diference):
Code: Select all
$re_msla2['descr'] .='<span><a href="search.php?id='. $row['id'] .'" title="link-text">'. $row[$col_desc[$i]] .'</a></span>';
And, the sql select must contains the id:
Code: Select all
$sql = "SELECT id, `$get_cols` FROM `$table`".$where;
- If it not works, copy-paste that message error.
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 10 Nov 2016, 05:51
by melmdoost
Hello, thank you for your response.
your code was true:
Code: Select all
$re_msla2['descr'] .='<span><a href="search.php?id='. $row['id'] .'" title="link-text">'. $row[$col_desc[$i]] .'</a></span>';
How do I use this code to query in 'msla2.php'?
Code: Select all
$result = mysqli_query($con,"SELECT * FROM $table ");
while($rows = mysqli_fetch_array($result)){
}
i want $row['id'] get id from code above.
in other words, i want each record of this script in 'filter-multiple-select-lists_s2', have a link.
As you know, each record in the table has an ID. I want to be sent to another page, each id of record at out put filter by clicking.
This code should be get any id of records and send to 'search.php?id=...'
thank you.
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 10 Nov 2016, 09:12
by Admin
I understand. And, what is not working?
What do you not know to do?
In the "search.php" get the id from url using:
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 10 Nov 2016, 09:45
by melmdoost
well, $rows['id'] is null!
my question:
how can i get id's of each record in out put this script?
i try this code in your script:
Code: Select all
$result = mysqli_query($conn,"SELECT * FROM $table ");
while($rows = mysqli_fetch_array($result)){
}
but it not works.
what is your opinion or your suggestion a bout that?
Final result in table, in MSLA2 - Multiple Select Lists
Posted: 10 Nov 2016, 10:16
by Admin
If the $rows['id'] is null, use
$row['id'] (without "s", because in that script it is set $row) in "msla2.php", and replace this code in :
Code: Select all
$sql = "SELECT `$get_cols` FROM `$table`".$where;
With this:
Code: Select all
$sql = "SELECT id, `$get_cols` FROM `$table`".$where;
And, if you want to make other sql query, use this format:
Code: Select all
$result = $conn->query("SELECT * FROM $table ");
while($row = $result->fetch_assoc()){
//...
}
- In the rest, i not know.