Final result in table, in MSLA2 - Multiple Select Lists

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
melmdoost
Posts: 20

Final result in table, in MSLA2 - Multiple Select Lists

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?

Admin Posts: 805
Hello
Final result is the description? What data you want in a table?
I do not understand what you want.
Did you try something?

melmdoost Posts: 20
hello,
Suppose, for example, output for the machine name, color and model. I want this to be displayed in a table.

Admin Posts: 805
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>';
}

melmdoost Posts: 20
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

Admin Posts: 805
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>';

melmdoost Posts: 20
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?

Admin Posts: 805
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.

melmdoost Posts: 20
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.

Admin Posts: 805
I understand. And, what is not working?
What do you not know to do?
In the "search.php" get the id from url using:

Code: Select all

$id = intval($_GET['id']);

melmdoost Posts: 20
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?

Admin Posts: 805
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.

Similar Topics